Rule playground
The Student guide has a rule, sample code and expected results you can compare with a local scan.
Check Keryn downloads for signed-in members. With the CLI installed, use the commands below to check and run your rule.
Rules use Keryn’s Semgrep-compatible syntax, which is a subset of Semgrep’s. Keryn runs pattern rules, including data-flow rules (mode: taint). Cross-file analysis and known-fix matching run in full scans.
In an empty folder, save the rule below as my-rule.yml.
rules: - id: example.debug-print languages: [python] severity: WARNING message: Remove debugging output before shipping. pattern: print(...)Save this sample as example.py in the same folder.
print("debug")Lint the rule, scan the folder and use jq to show the finding from this rule.
keryn rules lint my-rule.ymlkeryn scan . --rules my-rule.yml --fail-on none --json result.json -qjq -r '.findings[] | select(.ruleId == "example.debug-print") | "\(.path):\(.line) \(.ruleId)"' result.jsonmy-rule.yml: 1 rule(s)0 error(s), 0 warning(s)example.py:1 example.debug-printSee write your own rules.