The sanitized parameter modifier
The complete source of sanitized_modifier.ek9, compiled by the EK9 compiler. Shown on sanitized.html.
#!ek9 defines module site.sanitized.modifier defines function executeQuery() -> sql as sanitized String <- result as String? //The 'sql' parameter is sanitized on entry, //before any of this function's code runs - preventing SQL injection result: `executed ${sql}` processUserInput() -> name as sanitized String comment as sanitized String <- success as Boolean? //Both parameters are sanitized before use: a threat leaves one unset success: name? and comment? processInput() -> userInput as sanitized String //OK: sanitized at the definition - the target site <- rtn as String: userInput defines program SanitizedInUse() stdout <- Stdout() stdout.println(executeQuery("customer 42")) stdout.println($processUserInput("Ada", "Lovely day")) stdout.println(processInput("Ada"))
Download sanitized_modifier.ek9
Output
executed customer 42 true Ada