Repository navigation
fix(query): improve "last user is root" dockerfile query coverage #8123
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
Merged
cx-artur-ribeiro
merged 86 commits into
master
from
AST-179935-Improve-Last-User-is-root-coverage
Oct 1, 2026
+125
−31
Merged
Changes from 83 commits
Commits
Show all changes
86 commits
Select commit
Hold shift + click to select a range
5e5b42b
Changed identification of docker files to be case insensitive on file…
cx-andre-pereira d410ef8
removed legacy redundant function 'isDockerfile' from analyzer
cx-andre-pereira dd61304
Improved dockerfile identification to account for relevant folder nam…
cx-andre-pereira 9300974
Fixed 'dockerfile' keyword not being recognized as a valid file exten…
cx-andre-pereira c6b449d
Minor optimization
cx-andre-pereira bc352b4
Initial test files/cases plus minor changes to supported dockerfile f…
cx-andre-pereira 641eb16
Added new helper function 'isDockerfileExtension' to get_extension ut…
cx-andre-pereira a02c969
reverted accidental query change, fixed linting errors, fixed test er…
cx-andre-pereira a4dc3d3
linting fix and optimized case of file named dockerfile without exten…
cx-andre-pereira 4fc7fa4
More changes to fix go lint, d variable so 'dockerfile' is not used t…
cx-andre-pereira 215f9d4
Added samples for case insensitive testing on dockerfiles, added E2E …
cx-andre-pereira 552340c
fix for E2E
cx-andre-pereira 816fad5
Changed relevant functions to always treat/set the extension of valid…
cx-andre-pereira 45bafb3
Removed last mention of 'dockerfile' without dot notation
cx-andre-pereira 1e91259
Changed 'gitignore' check for better check order in 'GetExtension' fu…
cx-andre-pereira 426d3fc
Slightly more restrictive check to FROM command to ensure it has a tr…
cx-andre-pereira 3343c80
Updates to functions, removed unnecessary if statement on scan.go and…
cx-andre-pereira caec2cf
fix previous commit
cx-andre-pereira 8b4232f
fix analyzer uni tests
cx-andre-pereira e9ab29d
simplified new if condition
cx-andre-pereira 4f79e00
lint fix
cx-andre-pereira b7c14b9
fixed analyze unit tests, with names ending in 'gitignore' no longer …
cx-andre-pereira bfb6370
Case-insensitive unit tests for dockerfile samples
cx-andre-pereira 16f73f3
Slight changes to new test
cx-andre-pereira 4a0eb92
Slight simplification of new docker/parser unit test
cx-andre-pereira 04dd717
Mini fix on insensitive_sample
cx-andre-pereira a304aae
Changed E2E to 106 to fix merge conflict
cx-andre-pereira 15c22eb
fix E2E tests
cx-andre-pereira 40806ea
Final E2E fix
cx-andre-pereira bfb0e3b
Update to 'Docker' related documentation
cx-andre-pereira ec0307f
Requested change - made extDockerfile a constant
cx-andre-pereira 1ccf069
Fixed E2E 106 fixture 'RESULT' file name
cx-andre-pereira ae10784
Refactor to 'get_extension' and 'analyzer' to reduce redudancy
cx-andre-pereira 9307b95
Lint error fix
cx-andre-pereira 8541b79
Newline removed (lint)
cx-andre-pereira d22eaae
Renamed variable to prevent confusing shadowing
cx-andre-pereira 404517e
Requested E2E change
cx-andre-pereira 595055c
Removed .ubi8 and .debian extensions checks
cx-andre-pereira 6bdad99
Fallback on debian and ubi removal from docker/parser to test E2E
cx-andre-pereira 92005b5
E2E test 2
cx-andre-pereira 6f61b90
New 'python' samples to test for edge case 'from' statements on files…
cx-andre-pereira dcdb010
New samples and improved, tailored regex for dockerfile FROM statemen…
cx-andre-pereira 1a40ecc
Removed duplicated sample(negative) that was in positive test fixture…
cx-andre-pereira efd386c
Final fix for E2E plus the test file removal that should have been in…
cx-andre-pereira 95c6ea7
Made UrlRegex a constant
cx-andre-pereira 39cc71e
New samples, changed fockerfile syntax identification to aproach to e…
cx-andre-pereira 6b5de8d
Linter fix
cx-andre-pereira 780f9fb
The actual linter fix
cx-andre-pereira 6736f86
fix E2E payload files changed during rebase
cx-andre-pereira 62879ed
updated go and git base images
cx-andre-pereira 1ec74e9
Merge branch 'master' into AST-140477--Improvement-to-dockerfile-scan…
cx-andre-pereira 8c55d3c
fix test re using fs cuasing unexpected result during assert
cx-andre-pereira 0b9ac2b
go mod and sum
cx-andre-pereira eb5d42d
Merge branch 'master' into AST-140477--Improvement-to-dockerfile-scan…
cx-andre-pereira 18d09f8
go mod and sum update plus fix for filesystem test that is only valid…
cx-andre-pereira f0d4c9d
Merge branch 'master' of https://github.com/Checkmarx/kics into AST-1…
cx-andre-pereira bcb994b
Merge branch 'master' into AST-140477--Improvement-to-dockerfile-scan…
cx-andre-pereira 38faff7
Merge branch 'master' into AST-140477--Improvement-to-dockerfile-scan…
cx-andre-pereira 1c55e31
Merge branch 'master' into AST-140477--Improvement-to-dockerfile-scan…
cx-andre-pereira 29d7a3c
Merge branch 'master' of https://github.com/Checkmarx/kics into AST-1…
cx-andre-pereira 85e01dd
Actions re-trigger
cx-andre-pereira 0e84943
Merge master, aligned new worker pool aproach in analyzer with my ch…
cx-andre-pereira 735c067
Extracted file getter for path(s) to helper funcion (ci-lint fix - An…
cx-andre-pereira ce803ee
More linter fixes
cx-andre-pereira f0ec4df
Merge branch 'master' of https://github.com/Checkmarx/kics into AST-1…
cx-andre-pereira 954512f
Merge branch 'master' of https://github.com/Checkmarx/kics into AST-1…
cx-andre-pereira 66f1cea
Added alternative assertion in TestFileSystemSourceProvider_AddExclud…
cx-andre-pereira f7b9423
Improved test_too_many_levels_of_symbolic_links test for Windows erro…
cx-andre-pereira b120fff
Fix for the TestFileSystemSourceProvider_AddExcluded test, now with a…
cx-andre-pereira 4262645
Merge branch 'master' of https://github.com/Checkmarx/kics into AST-1…
cx-andre-pereira 0d0c155
Updated dockerfile git/go images
cx-andre-pereira 3eda269
Revert to correct go image
cx-andre-pereira ffab23c
Merge branch 'master' of https://github.com/Checkmarx/kics
cx-andre-pereira 754c8fb
Added missing possible root values and a test for each one
cx-andre-pereira 2ddf566
merge master
cx-andre-pereira cab86fd
Merge branch 'master' into AST-179935-Improve-Last-User-is-root-coverage
cx-andre-pereira 1a6d514
fix missing comma in expected results
cx-andre-pereira f04d810
Fix expected results again
cx-andre-pereira ac42f2c
Fix positive5
cx-andre-pereira 033d445
Merge branch 'master' into AST-179935-Improve-Last-User-is-root-coverage
cx-artur-ribeiro 2c225ca
add: detect root user with any group
cx-artur-ribeiro 691ae42
add: numeric integers that correlate to root user as well
cx-artur-ribeiro 01451d6
Merge branch 'master' into AST-179935-Improve-Last-User-is-root-coverage
cx-artur-ribeiro 7ceb40e
refactor: positive5 to the previous version, add positive 7 correct s…
cx-artur-ribeiro 4d9bb0a
Merge branch 'AST-179935-Improve-Last-User-is-root-coverage' of githu…
cx-artur-ribeiro bce32a6
Merge branch 'master' into AST-179935-Improve-Last-User-is-root-coverage
cx-artur-ribeiro File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
assets/queries/dockerfile/last_user_is_root/test/negative4.dockerfile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| FROM alpine:2.6 | ||
| USER root | ||
| RUN npm install | ||
| USER 1000:0 |
4 changes: 4 additions & 0 deletions
4
assets/queries/dockerfile/last_user_is_root/test/negative5.dockerfile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| FROM alpine:2.6 | ||
| USER root | ||
| RUN npm install | ||
| USER guest:root |
4 changes: 4 additions & 0 deletions
4
assets/queries/dockerfile/last_user_is_root/test/negative6.dockerfile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| FROM alpine:2.6 | ||
| USER root | ||
| RUN npm install | ||
| USER 01000 |
3 changes: 3 additions & 0 deletions
3
assets/queries/dockerfile/last_user_is_root/test/positive10.dockerfile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| FROM alpine:2.6 | ||
| USER 000 | ||
| RUN npm install |
3 changes: 3 additions & 0 deletions
3
assets/queries/dockerfile/last_user_is_root/test/positive11.dockerfile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| FROM alpine:2.6 | ||
| USER 00:1000 | ||
| RUN npm install |
3 changes: 3 additions & 0 deletions
3
assets/queries/dockerfile/last_user_is_root/test/positive12.dockerfile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| FROM alpine:2.6 | ||
| USER +0:wheel | ||
| RUN npm install |
3 changes: 3 additions & 0 deletions
3
assets/queries/dockerfile/last_user_is_root/test/positive13.dockerfile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| FROM alpine:2.6 | ||
| USER -0 | ||
| RUN npm install |
6 changes: 3 additions & 3 deletions
6
assets/queries/dockerfile/last_user_is_root/test/positive5.dockerfile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| from alpine:2.6 | ||
| user root | ||
| run npm install | ||
| FROM alpine:2.6 | ||
| USER root:0 | ||
| RUN npm install |
3 changes: 3 additions & 0 deletions
3
assets/queries/dockerfile/last_user_is_root/test/positive6.dockerfile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| FROM alpine:2.6 | ||
| USER 0:root | ||
| RUN npm install |
3 changes: 3 additions & 0 deletions
3
assets/queries/dockerfile/last_user_is_root/test/positive7.dockerfile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| from alpine:2.6 | ||
| user root | ||
| run npm install |
3 changes: 3 additions & 0 deletions
3
assets/queries/dockerfile/last_user_is_root/test/positive8.dockerfile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| FROM alpine:2.6 | ||
| USER root:wheel | ||
| RUN npm install |
3 changes: 3 additions & 0 deletions
3
assets/queries/dockerfile/last_user_is_root/test/positive9.dockerfile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| FROM alpine:2.6 | ||
| USER 0:1000 | ||
| RUN npm install |
108 changes: 78 additions & 30 deletions
108
assets/queries/dockerfile/last_user_is_root/test/positive_expected_result.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,32 +1,80 @@ | ||
| [ | ||
| { | ||
| "queryName": "Last User Is 'root'", | ||
| "severity": "HIGH", | ||
| "line": 2, | ||
| "fileName": "positive1.dockerfile" | ||
| }, | ||
| { | ||
| "queryName": "Last User Is 'root'", | ||
| "severity": "HIGH", | ||
| "line": 2, | ||
| "fileName": "positive2.dockerfile" | ||
| }, | ||
| { | ||
| "queryName": "Last User Is 'root'", | ||
| "severity": "HIGH", | ||
| "line": 2, | ||
| "fileName": "positive3.dockerfile" | ||
| }, | ||
| { | ||
| "queryName": "Last User Is 'root'", | ||
| "severity": "HIGH", | ||
| "line": 2, | ||
| "fileName": "positive4.dockerfile" | ||
| }, | ||
| { | ||
| "queryName": "Last User Is 'root'", | ||
| "severity": "HIGH", | ||
| "line": 2, | ||
| "fileName": "positive5.dockerfile" | ||
| } | ||
| { | ||
| "queryName": "Last User Is 'root'", | ||
| "severity": "HIGH", | ||
| "line": 2, | ||
| "fileName": "positive1.dockerfile" | ||
| }, | ||
| { | ||
| "queryName": "Last User Is 'root'", | ||
| "severity": "HIGH", | ||
| "line": 2, | ||
| "fileName": "positive2.dockerfile" | ||
| }, | ||
| { | ||
| "queryName": "Last User Is 'root'", | ||
| "severity": "HIGH", | ||
| "line": 2, | ||
| "fileName": "positive3.dockerfile" | ||
| }, | ||
| { | ||
| "queryName": "Last User Is 'root'", | ||
| "severity": "HIGH", | ||
| "line": 2, | ||
| "fileName": "positive4.dockerfile" | ||
| }, | ||
| { | ||
| "queryName": "Last User Is 'root'", | ||
| "severity": "HIGH", | ||
| "line": 2, | ||
| "fileName": "positive5.dockerfile" | ||
| }, | ||
| { | ||
| "queryName": "Last User Is 'root'", | ||
| "severity": "HIGH", | ||
| "line": 2, | ||
| "fileName": "positive6.dockerfile" | ||
| }, | ||
| { | ||
| "queryName": "Last User Is 'root'", | ||
| "severity": "HIGH", | ||
| "line": 2, | ||
| "fileName": "positive7.dockerfile" | ||
| }, | ||
| { | ||
| "queryName": "Last User Is 'root'", | ||
| "severity": "HIGH", | ||
| "line": 2, | ||
| "fileName": "positive8.dockerfile" | ||
| }, | ||
| { | ||
| "queryName": "Last User Is 'root'", | ||
| "severity": "HIGH", | ||
| "line": 2, | ||
| "fileName": "positive9.dockerfile" | ||
| }, | ||
| { | ||
| "queryName": "Last User Is 'root'", | ||
| "severity": "HIGH", | ||
| "line": 2, | ||
| "fileName": "positive10.dockerfile" | ||
| }, | ||
| { | ||
| "queryName": "Last User Is 'root'", | ||
| "severity": "HIGH", | ||
| "line": 2, | ||
| "fileName": "positive11.dockerfile" | ||
| }, | ||
| { | ||
| "queryName": "Last User Is 'root'", | ||
| "severity": "HIGH", | ||
| "line": 2, | ||
| "fileName": "positive12.dockerfile" | ||
| }, | ||
| { | ||
| "queryName": "Last User Is 'root'", | ||
| "severity": "HIGH", | ||
| "line": 2, | ||
| "fileName": "positive13.dockerfile" | ||
| } | ||
| ] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.