<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>samadhiweb</title><description>smalltalk programming for the web</description><link>http://samadhiweb.com/blog/</link><item><title>Fuzzing</title><author>Pierce Ng</author><link>http://samadhiweb.com/blog/2013.05.12.fuzzing.html</link><guid>http://samadhiweb.com/blog/2013.05.12.fuzzing.html</guid><pubDate>Sun, 12 May 2013 08:59:31 GMT</pubDate><description>&lt;p&gt;I&amp;rsquo;ve previously written about
&lt;a href=&quot;/blog/2012.11.25.sqlite.fts.html&quot;&gt;StackOverlow full text indexing using SQLite&lt;/a&gt;.
I&amp;rsquo;ve now loaded this site&amp;rsquo;s small body of content into an SQLite FTS
database, and have implemented a search interface for it. Before opening up
the search interface to the big bad Internet, I reckon some testing is
required.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://www.owasp.org/index.php/Fuzzing&quot;&gt;Fuzzing&lt;/a&gt; &amp;ldquo;is a black box software
testing technique which basically consists of finding implementation bugs
using malformed/semi-malformed data injection in an automated fashion.&amp;rdquo;
This site runs as a Zinc server delegate in Pharo Smalltalk. In fuzzing the
search interface, I will be fuzzing Zinc&amp;rsquo;s input handling, my server
delegate&amp;rsquo;s input handling including its susceptibility to SQL
injection, and possibly the CogVM FFI that hooks Pharo up with SQLite.&lt;/p&gt;

&lt;p&gt;Of course, the Smalltalk image is not a black box. While fuzzing I will be
able to view Zinc&amp;rsquo;s source code, explore live objects, and check behaviour.&lt;/p&gt;
</description></item><item><title>Mobile Smalltalk</title><author>Pierce Ng</author><link>http://samadhiweb.com/blog/2013.05.04.mobilesmalltalk.html</link><guid>http://samadhiweb.com/blog/2013.05.04.mobilesmalltalk.html</guid><pubDate>Sat, 04 May 2013 10:19:23 GMT</pubDate><description>&lt;p&gt;Peter Fisk has
&lt;a href=&quot;https://groups.google.com/forum/?fromgroups=#!topic/comp.lang.smalltalk/InQqT0AIUa4&quot;&gt;announced&lt;/a&gt;
&lt;a href=&quot;http://www.mobilesmalltalk.com/&quot;&gt;Mobile Smalltalk&lt;/a&gt;, a direct descendent of
QuickSilver Smalltalk which was mentioned in this
&lt;a href=&quot;/blog/2011.03.19.jtalk.html&quot;&gt;entry&lt;/a&gt; I posted two years ago.&lt;/p&gt;
</description></item><item><title>R.I.P. FileDirectory</title><author>Pierce Ng</author><link>http://samadhiweb.com/blog/2013.04.30.rip.filedirectory.html</link><guid>http://samadhiweb.com/blog/2013.04.30.rip.filedirectory.html</guid><pubDate>Tue, 30 Apr 2013 09:16:34 GMT</pubDate><description>&lt;p&gt;At heart, SmallCMS1, this blog&amp;rsquo;s content management system, walks
directories and processes files. Distilled, this code, originally written
interactively in a workspace, is what SmallCMS1 does:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;| startDir fileWalker dirWalker |

startDir := FileDirectory on: '/the/content/directory'.

fileWalker := [ :fileNames |
    fileNames do: [ :fname |
    Transcript show: '...', fname; cr ]].

dirWalker := [ :dir |
Transcript show: dir localName; cr.
    fileWalker value: dir fileNames.
    dir directoryNames do: [ :dname |
        | subDir |
        subDir := dir directoryNamed: dname.
        dirWalker value: subDir ]].

dirWalker value: startDir.
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;As of Pharo 2.0, FileDirectory has been replaced by FileSystem. The above
code still works using FileSystem, with minor changes:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;| startDir fileWalker dirWalker |

startDir := FileSystem / 'the' / 'content' / 'directory'.

fileWalker := [ :fileNames |
    fileNames do: [ :fname |
    Transcript show: '...', fname; cr ]].

dirWalker := [ :dir |
    Transcript show: dir basename; cr.
    fileWalker value: dir fileNames.
    dir directoryNames do: [ :dname |
        | subDir |
        subDir := dir / dname.
        dirWalker value: subDir ]].

dirWalker value: startDir.
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;FileSystem also implements the visitor pattern, which performs enumeration
and traversal on behalf of application code:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;| fs |
fs := FileSystem / 'the' / 'content' / 'directory'.
CollectVisitor preorder: fs collect: [ :e |
    e isFile ifTrue: [ Transcript show: '...' ].
    Transcript show: e basename; cr ].
&lt;/code&gt;&lt;/pre&gt;
</description></item><item><title>PostgresV3 Protocol State Machine using GraphViz</title><author>Pierce Ng</author><link>http://samadhiweb.com/blog/2013.04.28.graphviz.postgresv3.html</link><guid>http://samadhiweb.com/blog/2013.04.28.graphviz.postgresv3.html</guid><pubDate>Sun, 28 Apr 2013 10:20:32 GMT</pubDate><description>&lt;p&gt;In the &lt;a href=&quot;/blog/2013.04.28.postgresv3.html&quot;&gt;previous post&lt;/a&gt; I wrote about
visualizing the &lt;a href=&quot;http://squeaksource.com/PostgresV3&quot;&gt;PostgresV3&lt;/a&gt; pure Smalltalk
implementation of the PostgreSQL v3 wire protocol. That &amp;ldquo;visualization&amp;rdquo; was
in text, which is not nearly as visual as seeing the protocol state machine
graphically.&lt;/p&gt;

&lt;p&gt;In this post, let&amp;rsquo;s use
&lt;a href=&quot;http://squeaksource.com/GraphViz&quot;&gt;GraphViz&lt;/a&gt; to do that. Building on the
code previously written:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;| skip states statesMap gv |

skip := #('PG3NoticeResponse' 'PG3NotificationResponse' 'PG3ParameterStatus').
states := OrderedCollection new.

PG3ServerState createStateGraph valuesDo: [ :inst |
    inst transitions keysAndValuesDo: [ :k :v |
        (skip includes: k asString) ifFalse: [
        states add: (Array with: inst with: k with: v first with: v second) ]]].

states do: [ :ea |
    Transcript show: 'From ', ea first name; 
        show: ' on ', ea second asString.
        ea fourth ifNotNil: [ Transcript show: ' perform #', ea fourth ].
    Transcript show: ' goto ', ea third name; cr; flush ].

statesMap := Dictionary new.
states do: [ :ea |
    (statesMap includesKey: ea first name) ifFalse: [
        statesMap at: ea first name put: OrderedCollection new ].
    (statesMap at: ea first name) add: ea ].

gv := GraphViz new.
gv beDirected;
    name: 'PostgresV3 Protocol State Machine';
    add: #graph with: { #overlap -&amp;gt; #scale. #concentrate -&amp;gt; #true };
    add: #edge with: { #arrowsize -&amp;gt; 0.5 }.

statesMap keysAndValuesDo: [ :k :v |
    gv add: k with: { #shape -&amp;gt; #box. #fontsize -&amp;gt; 10 }.
    v do: [ :ea |
        gv add: ea third name with: { #shape -&amp;gt; #box. #fontsize -&amp;gt; 10 }.
        gv add: k -&amp;gt; ea third name with: { #label -&amp;gt; ea second asString. #fontsize -&amp;gt; 8 } ]].

gv openInWindow.
&lt;/code&gt;&lt;/pre&gt;

&lt;div class=&quot;image-box&quot;&gt;
&lt;img src=&quot;/img/gv.pgv3.png&quot; width=&quot;600&quot; alt=&quot;Graphviz PostgresV3 Protocol State Machine&quot; /&gt;
&lt;/div&gt;



</description></item><item><title>PostgresV3 Protocol State Machine</title><author>Pierce Ng</author><link>http://samadhiweb.com/blog/2013.04.28.postgresv3.html</link><guid>http://samadhiweb.com/blog/2013.04.28.postgresv3.html</guid><pubDate>Sun, 28 Apr 2013 09:42:52 GMT</pubDate><description>&lt;p&gt;&lt;a href=&quot;http://squeaksource.com/PostgresV3&quot;&gt;PostgresV3&lt;/a&gt; is a pure Smalltalk
implementation of the PostgreSQL v3 wire protocol (and a database access
API) by Levente Uzonyi and Balazs Kosi.&lt;/p&gt;

&lt;p&gt;In code, the protocol is implemented as a state machine, created by
&amp;ldquo;PG3ServerState createStateGraph&amp;rdquo;, which invokes methods such as this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;initializingBackendStateDescription

    (self state: #InitializingBackend)
        on: PG3BackendKeyData
        connectionDo: #registerBackendKeyData:
        goto: #InitializingBackend;

        on: PG3ReadyForQuery
        connectionDo: #readyForQuery:
        goto: #WaitingForQuery
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&amp;ldquo;on:connectionDo:goto:&amp;rdquo; looks like this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;on: aPG3MessageClass connectionDo: selector goto: aSymbol
    transitions at: aPG3MessageClass put: { (self state: aSymbol). selector }
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I wanted to map out all state transitions, to better visualize the protocol
flow. This is done by walking through the &amp;ldquo;transitions&amp;rdquo; inst-var of each
instance of PG3ServerState:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;| skip states |

skip := #('PG3NoticeResponse' 'PG3NotificationResponse' 'PG3ParameterStatus').
states := OrderedCollection new.

PG3ServerState createStateGraph valuesDo: [ :inst |
    inst transitions keysAndValuesDo: [ :k :v |
        (skip includes: k asString) ifFalse: [
            states add: (Array with: inst with: k with: v first with: v second) ]]].

states do: [ :ea |
    Transcript show: 'From ', ea first name; 
        show: ' on ', ea second asString.
    ea fourth ifNotNil: [ Transcript show: ' perform #', ea fourth ].
    Transcript show: ' goto ', ea third name; cr; flush ].
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Here&amp;rsquo;s the output:&lt;/p&gt;

&lt;pre&gt;
    From InitializingBackend on PG3ReadyForQuery perform #readyForQuery: goto WaitingForQuery
    From InitializingBackend on PG3BackendKeyData perform #registerBackendKeyData: goto InitializingBackend
    From GotDataRow on PG3ErrorResponse perform #handleError: goto GotErrorResponseDuringSimpleQuery
    From GotDataRow on PG3CommandComplete perform #commandComplete: goto GotCommandComplete
    From GotDataRow on PG3DataRow perform #dataRow: goto GotDataRow
    From GotErrorResponseDuringSimpleQuery on PG3ReadyForQuery perform #readyForQuery: goto WaitingForQuery
    From GotEmptyQueryResponse on PG3ReadyForQuery perform #readyForQuery: goto WaitingForQuery
    From GotEmptyQueryResponse on PG3ErrorResponse perform #handleError: goto GotErrorResponseDuringSimpleQuery
    From Querying on PG3ErrorResponse perform #handleError: goto GotErrorResponseDuringSimpleQuery
    From Querying on PG3CommandComplete perform #commandComplete: goto GotCommandComplete
    From Querying on PG3RowDescription perform #rowDescription: goto GotRowDescription
    From Querying on PG3EmptyQueryResponse goto GotEmptyQueryResponse
    From Authenticating on PG3AuthenticationMD5Password perform #respondToAuthenticationMD5PasswordRequest: goto AuthenticatingWithMD5
    From Authenticating on PG3AuthenticationOkMessage goto InitializingBackend
    From AuthenticatingWithMD5 on PG3AuthenticationOkMessage goto InitializingBackend
    From GotCommandComplete on PG3ReadyForQuery perform #readyForQuery: goto WaitingForQuery
    From GotCommandComplete on PG3ErrorResponse perform #handleError: goto GotErrorResponseDuringSimpleQuery
    From GotCommandComplete on PG3CommandComplete perform #commandComplete: goto GotCommandComplete
    From GotCommandComplete on PG3RowDescription perform #rowDescription: goto GotRowDescription
    From GotRowDescription on PG3ErrorResponse perform #handleError: goto GotErrorResponseDuringSimpleQuery
    From GotRowDescription on PG3CommandComplete perform #commandComplete: goto GotCommandComplete
    From GotRowDescription on PG3DataRow perform #dataRow: goto GotDataRow
&lt;/pre&gt;


&lt;p&gt;&amp;nbsp;&lt;/p&gt;
</description></item></channel></rss>