Skip to content

    Type a page, a command such as keryn scan, or a rule id.

    Rule playground

    View as Markdown

    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.

    Terminal window
    keryn rules lint my-rule.yml
    keryn scan . --rules my-rule.yml --fail-on none --json result.json -q
    jq -r '.findings[] | select(.ruleId == "example.debug-print") | "\(.path):\(.line) \(.ruleId)"' result.json
    my-rule.yml: 1 rule(s)
    0 error(s), 0 warning(s)
    example.py:1 example.debug-print

    See write your own rules.