Detector Engine

Query Structure

Detectors are composed of rules, or queries that are compiled into an efficient detector and are run with the Code Security engine against files.

Each query is a group of patterns, called a pattern_group and is hierarchical (a pattern group can contain more pattern groups and so on).

A pattern group is a collection of patterns with an aggregate relation.

Copy
    pattern_group:
      aggregate: or | and | append
      patterns:
      - pattern: "(:?key|token|secret|password|pwd|passwd)=(.*)" # assignment
        pattern_type: single
      - pattern: "hello" # assignment
        pattern_type: multi

Prematch Testers

A prematch tester is a test that runs before applying an in-depth matching and detection logic. As an example, it is more appropriate to use bail out detection for a small binary file with class documentation.

Content Testers

Structural Testers

Semantic Testers

Testing Detector

To test, you can selectively include your new detectors by using --just-ids and/or --just-tags. With these you can use any of the common Code Security commands:

If you want to run your new rule on your entire Github org:

Copy
$HOME/.spectral/spectral github ... --just-ids PRV001

Alternatively, just to scan your current repo:

Copy
$HOME/.spectral/spectral run ... --just-tags acme-security

Submit the Detector for Review

Contact Check Point Support Center to review your detector. Ensure to redact sensitive information in the detector before your submit it. Check Point can help you build it and give you a free detector building session.