Repository navigation
Add maxissues threshold support for CI/CD rule enforcement #15
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
Changes from 2 commits
b2cc489
2c71736
bbe8165
3681423
15621c4
7ce279b
9fd7d8b
4e58b79
598f280
6728621
5b41966
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -129,6 +129,25 @@ func (c *Config) GetCICDRuleIds() []rules.RuleID { | |
| return ruleIds | ||
| } | ||
|
|
||
| /** | ||
| * Returns the max allowed issues for a specific rule ID. | ||
| * Returns ruleoverrides.<rule>.maxissues if set, otherwise 0. | ||
| */ | ||
| func (c *Config) GetRuleMaxIssues(ruleId rules.RuleID) int { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure but should GetRuleMaxIssues also be renamed to GetRuleCicdMaxIssues?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't mind it, I think the method is clear. But happy to change it if you feel like it should be renamed
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's okay to me. |
||
| if c == nil || c.RuleOverrides == nil { | ||
| return 0 | ||
| } | ||
|
|
||
| // Check if maxissues is explicitly set in ruleoverrides | ||
| if override, exists := c.RuleOverrides[string(ruleId)]; exists { | ||
| if override.MaxIssues != nil { | ||
| return *override.MaxIssues | ||
| } | ||
| } | ||
|
|
||
| return 0 | ||
| } | ||
|
|
||
| /** | ||
| * GetEnabledOverridedStandardRuleIds - Return the standard rule Ids | ||
| * Where RuleOveride property is defined and override rules enabled property is set to true or nil | ||
|
|
||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Future enhancement I might do, is make the index/readme copy from a central file with these details so I don't need to copy-paste across except for the headers/footers. Maybe it does and I just didn't see it? |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -57,7 +57,6 @@ Alternatively: | |
| - To cross-compile: `GOOS=windows GOARCH=amd64 go build -o asist.exe .` | ||
| - To build binaries for the most common platforms, run: `make build-binaries` | ||
|
|
||
|
|
||
| ## 🕹️ Usage | ||
|
|
||
| To see the help, run: | ||
|
|
@@ -198,12 +197,12 @@ Configuration files can also be explicitly specified using the `-c` argument (no | |
|
|
||
| Within the config file, you can: | ||
|
|
||
| * Enable/disable all the standard rules | ||
| * Override certain properties of standard rules | ||
| * Exclude files or directories for all rules | ||
| * Exclude files or directories for specific rules | ||
| * Add custom regex rules | ||
| * Define rules to be run in CI/CD mode | ||
| - Enable/disable all the standard rules | ||
| - Override certain properties of standard rules | ||
| - Exclude files or directories for all rules | ||
| - Exclude files or directories for specific rules | ||
| - Add custom regex rules | ||
| - Define rules to be run in CI/CD mode | ||
|
|
||
| See our [example config file](https://github.com/certinia/asist/blob/main/.asist.example.yaml) for a walkthrough of all config options. | ||
|
|
||
|
|
@@ -212,6 +211,7 @@ See our [example config file](https://github.com/certinia/asist/blob/main/.asist | |
| Users can override certain properties of standard rules according to their needs, allowing them to customize the behavior of specific rules by: | ||
|
|
||
| - Disabling rules entirely: `enabled` | ||
| - Limiting the number of allowed rule violations: [`maxissues`](#rule-max-issues) | ||
| - Tweaking rule severity: `severity` | ||
| - Tweaking what files should be scanned: `includepattern` | ||
| - Tweaking what files should not be scanned: `excludepattern` | ||
|
|
@@ -235,7 +235,6 @@ customregexrules: | |
|
|
||
| You can test this specific rule like this: | ||
|
|
||
|
|
||
| ```shell | ||
| asist -c .asist.yaml -r doNotDebug <file> | ||
| ``` | ||
|
|
@@ -283,11 +282,33 @@ In this mode, by default, all enabled runs will be run if `cicdrules` property i | |
| cicdrules: | ||
| - "XSSLabel" | ||
| - "XSSMergeField" | ||
| - "XSSDomHtml" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this list be alphabetical? |
||
| ``` | ||
|
|
||
| This allows developers to add a subset of the overall ruleset to ASIST to their CI/CD pipelines, and gradually add more rules to CI/CD as they start clearing out findings for other rules. This prevents any issues for rules defined in `cicdrules` from creeping back into the codebase. | ||
|
|
||
| ### 📊 Baseline scans | ||
| ## Rule Max Issues | ||
|
|
||
| When introducing ASIST to an existing codebase, you may have pre-existing security issues that you want to prevent from increasing while you work on fixing them. The `maxissues` property in [`ruleoverrides`](#-customizing-standard-rules) allows you to set maximum allowed issue counts for specific rules. | ||
|
|
||
| **By default, rules have a limit of 0 issues.** When a rule exceeds its `maxissues` threshold, ASIST will exit with an error code (see [Exit Codes](#-exit-codes)). You only need to set `maxissues` if you want to allow existing issues while preventing them from growing. | ||
|
|
||
| ```yaml | ||
| ruleoverrides: | ||
| XSSLabel: | ||
| maxissues: 150 # Allow up to 150 XSSTooltip issues (grandfather existing issues) | ||
| XSSMergeField: | ||
| maxissues: 0 # Explicitly set to 0 (same as default - no issues allowed) | ||
| # XSSDomHtml has no maxissues set, defaults to 0 (no issues allowed) | ||
| ``` | ||
|
|
||
| This feature allows you to: | ||
|
|
||
| - Gradually introduce stricter security requirements by lowering maxissues over time | ||
| - Prevent technical debt from growing while you address existing issues | ||
| - Start enforcing security on a codebase with 150 existing issues, then reduce to 100, 50, and eventually 0 | ||
|
|
||
| ## 📊 Baseline scans | ||
|
|
||
| This mode is intended for SecOps teams to create benchmarks across multiple projects and measure the adoption of ASIST. | ||
|
|
||
|
|
@@ -305,32 +326,32 @@ This command will output a JSON like this (when formatted): | |
|
|
||
| ```json | ||
| [ | ||
| { | ||
| "RepositoryName": "certinia/asist", | ||
| "RepositoryURL": "git@github.com:certinia/asist.git", | ||
| "RecordType": "Finding", | ||
| "Content": { | ||
| "FindingID": "b17fe249915712219aca7e", | ||
| "IsCustom": false, | ||
| "IsFalsePositive": true, | ||
| "RuleID": "LwcNonStandardPositioning", | ||
| "Severity": "Medium", | ||
| "RuleCategory": "Security" | ||
| } | ||
| }, | ||
| { | ||
| "RepositoryName": "certinia/asist", | ||
| "RepositoryURL": "git@github.com:certinia/asist.git", | ||
| "RecordType": "Finding", | ||
| "Content": { | ||
| "FindingID": "3a2861bee641864816b86d", | ||
| "IsCustom": false, | ||
| "IsFalsePositive": true, | ||
| "RuleID": "LwcNonStandardPositioning", | ||
| "Severity": "Medium", | ||
| "RuleCategory": "Security" | ||
| } | ||
| } | ||
| { | ||
| "RepositoryName": "certinia/asist", | ||
| "RepositoryURL": "git@github.com:certinia/asist.git", | ||
| "RecordType": "Finding", | ||
| "Content": { | ||
| "FindingID": "b17fe249915712219aca7e", | ||
| "IsCustom": false, | ||
| "IsFalsePositive": true, | ||
| "RuleID": "LwcNonStandardPositioning", | ||
| "Severity": "Medium", | ||
| "RuleCategory": "Security" | ||
| } | ||
| }, | ||
| { | ||
| "RepositoryName": "certinia/asist", | ||
| "RepositoryURL": "git@github.com:certinia/asist.git", | ||
| "RecordType": "Finding", | ||
| "Content": { | ||
| "FindingID": "3a2861bee641864816b86d", | ||
| "IsCustom": false, | ||
| "IsFalsePositive": true, | ||
| "RuleID": "LwcNonStandardPositioning", | ||
| "Severity": "Medium", | ||
| "RuleCategory": "Security" | ||
| } | ||
| } | ||
| ] | ||
| ``` | ||
|
|
||
|
|
@@ -341,15 +362,14 @@ A few differences can be observed compared to regular scans: | |
| - Each issue is assigned a `FindingID`, which is effectively a hash that uniquely identifies the finding based on the rule, the finding location, and if it's a false positive or not. | ||
| - A few more properties are added, such as if the rule is custom, or if the finding is marked as false positive or not. | ||
|
|
||
|
|
||
| ### 🫣 .gitignore and .forceignore files | ||
| ## 🫣 .gitignore and .forceignore files | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did some nitpicking, a H1 -> H3. Arguably this should have stayed a H3 and CI/CD should be a H2 but... |
||
|
|
||
| By default, ASIST will ignore files and folders defined inside .gitignore and .forceignore. If you don't want ASIST to respect .gitignore and .forceignore, you can use the following properties in the config file: | ||
|
|
||
| - **dontgitignore** | ||
| - **dontforceignore** | ||
|
|
||
| ### ⍈ Exit Codes | ||
| ## ⍈ Exit Codes | ||
|
|
||
| | Exit code | Exit Reason | | ||
| | --------- | -------------------------------------------------------- | | ||
|
|
@@ -405,5 +425,5 @@ This extension is shipped with prebuilt ASIST binaries, but if you need to speci | |
|
|
||
| 1. Open the ASIST `Extension settings` | ||
| 1. Navigate to the `Workspace` tab | ||
| 2. Enable the `Custom Binary Enabled` setting | ||
| 3. Provide the path to your ASIST binary in `Custom Binary Path` | ||
| 1. Enable the `Custom Binary Enabled` setting | ||
| 1. Provide the path to your ASIST binary in `Custom Binary Path` | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Context: 1. 1. 1 etc is valid for MD, it auto-increments. |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.