-
Notifications
You must be signed in to change notification settings - Fork 321
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
feat(engine): semantic exit code based on results (#2400) (#1721) #2726
Conversation
To comment on the suggestion - I think the error code should not provide insight on the results scan (e.g. info, medium. high) but only if the scan was finished successfully or not. The "--force" should allow ignoring problems in the scan like faulty queries, resource problems and so on. To achieve the results insight, we should have a tool that can evaluate the result and show the both statistics or the highest severity detected. So the automation flow would be 1. checking kics run OK (and produced a report) and 2. evaluate the report. |
This is @joaoReigota1 first draft proposal of the semantic exit status codes, with the addition of the Please add your comments and concerns so we can find the best strategy for this feature: @markmishaevcx @ruigomescx @nunoocx @kaplanlior @elit-cx @felipe-avelar @KojanAbzakh @AdarWeidman Results Status Code
Error Status Code
|
Hi,
Very good idea.
How about using a binary indicator for the status? For instance:
8 - High results found
4 - Medium results found
2 - Low results found
1 - Best Practice results found
This way if we find a combination we can kust add tge statuses, for instance
High+Low == 8+2 = 10
And so on.
What do you think?
Adar.
בתאריך יום ה׳, 8 באפר׳ 2021, 19:13, מאת Rogerio Peixoto <
***@***.***>:
… This is @joaoReigota1 <https://github.com/joaoReigota1> first draft
proposal of the semantic exit status codes, with the addition of the
--force flag that forces 0 status code unless an engine error is
triggered.
Please add your comments and concerns so we can find the best strategy for
this feature: @markmishaevcx <https://github.com/markmishaevcx>
@ruigomescx <https://github.com/ruigomescx> @nunoocx
<https://github.com/nunoocx> @kaplanlior <https://github.com/kaplanlior>
@elit-cx <https://github.com/elit-cx> @felipe-avelar
<https://github.com/felipe-avelar> @KojanAbzakh
<https://github.com/KojanAbzakh> @AdarWeidman
<https://github.com/AdarWeidman>
Results Status Code
Code Description
0 No Results were Found
50 Found only HIGH Results
40 Found only MEDIUM Results
30 Found only LOW Results
20 Found only INFO Results
59 Found Results with all severities
57 Found HIGH, MEDIUM and LOW Results
56 Found HIGH, MEDIUM and INFO ResultS
55 Found HIGH, INFO and LOW Results
54 Found HIGH, and MEDIUM Results
53 Found HIGH, and LOW Results
52 Found HIGH, and INFO Results
45 Found MEDIUM, INFO and LOW Results
43 Found MEDIUM, and LOW Results
42 Found MEDIUM, and INFO Results
32 Found LOW, and INFO Results Error Status Code
Code Description
126 Engine Error
130 Signal-Interrupt
110 Failed to detect line
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2726 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AJVYIXUF5UK7JF5ADFYS3UTTHXI2TANCNFSM42QPP2YA>
.
|
Hi, IMO, we should keep it simple, because the addition of these status code options is to allow an integration of KICS with a CI to break a build in case of found vulnerabilities. The user could then configure it's CI to break the build, for example, when it found HIGH and MEDIUM vulnerabilities. So, in that regard, I think the status code should be directed to:
The numbering can be decided to number of your choosing, I just think the logic should target these specific cases, because I believe that it will be the most common use case. I think the combining logic can become very cumbersome and won't be used (will anyone want to pick only HIGH and INFO results?) Also regarding Error Status Code, we should be very specific about this, because we will only return one status code, so we should not hinder status code for results not appearing if we have some error on a line detection that can occur. |
Hi, I agree with @ruigomescx. KISS!
Now we should provide appropriate codes. |
I expect this option to break some CI scripts, mostly ones which try running |
@kaplanlior I think this feature is about giving the user the option to fail the pipeline if KICS finds results without having to make him do additional work in their pipelines Based on the current feedback we have I propose we move for:
Results Status Code
Error Status Code
E.g using Jenkins scripted pipelines before this feature, the user would have to: def outputPath = "results.json"
def kicsCommand = "kics --no-progress -p \${PWD} -o ${outputPath} --report-formats json"
docker.image('checkmarx/kics:nightly-alpine').inside() {
ansiColor('xterm') {
sh(kicsCommand)
def results = readJSON(file: outputPath)
assert results['severity_counters']['HIGH'] == 0
}
} After, the user would just have to: docker.image('checkmarx/kics:nightly-alpine').inside() {
ansiColor('xterm') {
sh("kics --no-progress --fail-on-high -p \${PWD} -o ${outputPath} --report-formats json")
}
} The user can also get the status code and do something about it in a similar way as before: docker.image('checkmarx/kics:nightly-alpine').inside() {
ansiColor('xterm') {
def exitCode = sh(script:"kics --no-progress --fail-on-high -p \${PWD} -o ${outputPath} --report-formats json", returnStatus:true)
assert exitCode <= 40 : "Should not have HIGH severity results'
}
} When it comes to GitLab and other CI/CD tools it gets even simpler after this change: It will not require the user to do this shell-fu to break the pipeline kics scan -q /usr/bin/assets/queries -p ${PWD} -o ${PWD}/kics-results.json
# get HIGH results
export SEVERITY_COUNTER_HIGH=`grep '"HIGH"':' ' kics-results.json | awk {'print $2'} | sed 's/.$//'`
# check if HIGH results > 0
if [ "$SEVERITY_COUNTER_HIGH" -ge "1" ];then echo "Please fix all $SEVERITY_COUNTER_HIGH HIGH SEVERITY ISSUES" && exit 1;fi Can we agree on this? |
I really liked the solution proposed by @rogeriopeixotocx. |
Rectifying flags after feedback:
|
Maybe adding a small example in the flag description like @felipe-avelar suggested: |
Thanks for considering my feedback, even if you disagree. --force flag should be about continuing the scan even if errors occurs on the way, |
What if the name is different? something like Or to be aligned with the other options: |
Rectifying flag proposal after feedback:
Results Status Code
Error Status Code
|
Only adding to this comment, I think we should have a default value for the new flags. With this suggestions, updating @rogeriopeixotocx comment with this observations, flags would look like:
|
Signed-off-by: Felipe Avelar <[email protected]>
Signed-off-by: Felipe Avelar <[email protected]>
Signed-off-by: Felipe Avelar <[email protected]>
Signed-off-by: Felipe Avelar <[email protected]>
Signed-off-by: Felipe Avelar <[email protected]>
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.
LGTM
No description provided.