-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
use form of rule schema to deny broken rules #120
Comments
it is possible to use semgreps own validation: https://semgrep.dev/docs/writing-rules/testing-rules#validating-rules semgrep scan --metrics=off --validate --config /app/rules --json -o broken_rules.json Broken rules would result in the following {
"errors": [
{
"code": 4,
"level": "error",
"long_msg": "One of these properties is missing: 'languages'",
"short_msg": "Invalid rule schema",
"spans": [
{
"end": {
"col": 1,
"line": 27,
"offset": -1
},
"file": "rules/deny-default-namespace.yaml",
"source_hash": "c16ac57d9db7bb7c762e3775cf1982c20eb2161542acf11b32b04edc26730dea",
"start": {
"col": 3,
"line": 2,
"offset": -1
}
}
],
"type": "InvalidRuleSchemaError"
},
{
"code": 2,
"level": "error",
"message": "Semgrep match found at line ./rules/deny-default-namespace.yaml:2:\n Please include a 'languages' field for your rule $RULEID!",
"path": "./rules/deny-default-namespace.yaml",
"type": "Semgrep match found"
},
{
"code": 2,
"level": "error",
"message": "Rule parse error in rule restrict-image-registry:\n Missing required field regex",
"rule_id": "restrict-image-registry",
"type": "Rule parse error"
}
],
"paths": {
"scanned": []
},
"results": [],
"skipped_rules": [],
"version": "1.68.0"
}
There is no definite way to determine the path to a broken rule when scanning multiple rules. In summary, some considerations are necessary:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
semgr8s loads rules from remote and configmaps. a single broken rule could break the policy engine as a whole. rules are also frequently updated. rules must be scanned against a schema to ensure broken rules cannot enter the system.
also important: document this schema, specifically 1 rule in 1 configmap, multiple rules in multiple configmaps, multiple rules in 1 configmap
The text was updated successfully, but these errors were encountered: