Skip to content

fix(analyzer): improvement to dockerfile scanning - #7995

Closed
cx-andre-pereira wants to merge 66 commits into
Checkmarx:masterfrom
cx-andre-pereira:AST-140477--Improvement-to-dockerfile-scanning
Closed

cx-andre-pereira wants to merge 66 commits into
Checkmarx:masterfrom
cx-andre-pereira:AST-140477--Improvement-to-dockerfile-scanning

Conversation

@cx-andre-pereira

@cx-andre-pereira cx-andre-pereira commented Mar 11, 2026 •

Copy link
Copy Markdown
Contributor

Reason for Proposed Changes
The current implementation for dockerfile scanning is overly restrictive. The GetExtension function can identify "dockerfile" type files in two ways as of now:

  • Using the Contains function on files that have no extension set, allowing detection of files that contain "Dockerfile" in a case-sensitive way, values such as:
   - "Dockerfile"
   - "123Dockerfile"
   - "Dockerfile123" 
  • Checking that a file is:

    • a valid text file and then, through the "readPossibleDockerFile" function:
      • Return true immediately if it is a file with suffix "gitignore"
      • Return true if it contains a "FROM" (case-sensitive) command after skipping any commented lines "# ...";
    • Given all these conditions, the result for "GetExtension" will be "possibleDockerfile". As a final check for the file to be included in a given scan, the analyzer's worker calls the "isDockerfile" function meant to ensure that only files containing the "FROM" and "RUN"(both case-sensitive) commands are scanned, files that fail this check are promptly set as "unwanted".
  • The way dockerfile identification is meant to work is as follows:

    • Case-insensitive support for all "dockerfile", "dockerfile.any_extension" and "any_name.dockerfile" files.
    • Check all files inside folders with the names : "docker/", "dockerfile/" or "dockerfiles/", also in a case-insensitive manner.
  • Additionally ".ubi8" and ".debian" files should be included in the scan if they are valid docker configurations.

  • The current implementation has a plethora of issues:

    • It is case-sensitive both for "Dockerfile" identification as well as command scanning which is case-sensitive by convention only.
    • Restricts dockerfile scanning to those that contain the "FROM" and "RUN" commands when the "FROM" would suffice.
    • Does not properly skip empty lines and "ARG" type arguments when searching for the "FROM" statement in the "readPossibleDockerFile" function.
    • Has a major redundancy by using both the "readPossibleDockerFile" and the "isDockerfile" functions. Both serve identical purposes and since the latter is only called when "readPossibleDockerFile" returns a positive result, this check should be simplified into a single function.

Proposed Changes

  • Reworked the "GetExtension" function so that it first :

    • Calls the (new) "isDockerfileExtension" function, here all files that are named "dockerfile.something" or "something.dockerfile" in a case-insensitive manner, or files inside the target folders mentioned before that are deemed valid dockerfile files (through "readPossibleDockerFile") will be immediately determined as ".dockerfile" files.
  • The "readPossibleDockerFile" function was changed to support both "ARG" commands as well as empty lines before the "FROM" command. Additionally the order of these checks was changed to enhance performance so that it is first checked if a line is not a "FROM" command; previously, since every line was compared to the "FROM" statement, a file with a large number of comments would take significantly longer to skim through. (tests on a dockerfile with 260 thousand comments were two times faster with this change)

  • In the analyzer the worker was simplified, given the changes on the utils/get_extension's "GetExtension" function, we only need to worry about 2 results "gitignore" and ".dockerfile" , additionally the "isDockerfile" function is now gone; it was overly restrictive and served the same purpose as the "readPossibleDockerFile" function does now.

  • Unified all "dockerfile" type resource references to ".dockerfile", previously there was use of "dockerfile", "Dockerfile" and "possibleDockerfile", I deemed these unnecessary since they all represent the same thing, except for "possibleDockerfile" but files labeled as such could and are now determined as valid dockerfiles before being attributed a value for their "extension".

  • After initial reviews the case handling for "gitignore" values was simplified so that any ".gitignore" or any extensionless file with "gitignore" as a suffix will have identical flows, previously unit-tests for the analyzer forced the latter to be added to the "unwanted" path list, the test failed if we simple discarded the file in the analyze function before calling the worker (the way any invalid extension outside target folders is treated).

  • Tests

    Many new files were added to test/fixtures/dockerfile as well as a new folder test/fixtures/negative_dockerfile.

  • test/fixtures/dockerfile/

  ├── Dockerfile-example                (pre-existing test)                               
  ├── corrupted_dockerfile              (pre-existing test)
  ├── any_name/                                                                                                                                                                                                                    
  │   ├── DOCKERfile.txt
  │   ├── Dockerfile.something                                                                                                                                                                                                     
  │   ├── any_name.debian                                                                                                                         
  │   ├── any_name.ubi8
  │   ├── dockerFILE
  │   ├── file.Dockerfile
  │   ├── file_2.DOCKERfile
  │   └── random_name
  ├── case_insensitive_tests/
  │   ├── DOCKERfile.txt
  │   ├── Dockerfile.something
  │   ├── any_name.debian
  │   ├── any_name.ubi8
  │   ├── dockerFILE
  │   ├── file.Dockerfile
  │   ├── file_2.DOCKERfile
  │   └── random_name
  ├── should_generate_payload/
  │   ├── base_image_reference
  │   ├── big_host_name
  │   ├── big_indent_from
  │   ├── full_sha_digest
  │   ├── host_ip_address
  │   ├── multiline_from_statement
  │   ├── platform_flag
  │   ├── platform_flag_and_alias
  │   ├── platform_flag_scratch
  │   ├── platform_with_arg_reference
  │   ├── use_of_host
  │   └── with_excluded_comments
  ├── test_folder_names/
  │   ├── docker/
  │   │   └── any_file.txt
  │   ├── dockerfile/
  │   │   └── any_file.txt
  │   └── dockerfiles/
  │       └── any_file.txt
  └── test_folder_names_case/
      ├── Docker/
      │   └── any_file.txt
      ├── Dockerfile/
      │   └── any_file.txt
      └── Dockerfiles/
          └── any_file.txt

The files themselves include configurations with empty lines, ARG commands and comments before the target FROM command. Additionally all naming conventions are tested. Note that files inside the target folders would not be identified if they were not inside said folders (because isDockerfileExtension is called before checking literal extension).

The case_insensitive_tests folder includes identical tests where all docker commands have been written in lowercase — note that most queries logic / the engine itself will not properly allow final results pointing to target lines when a query is triggered, but they still trigger similarly to comparable conventional dockerfiles (fixed in #8006).

Lastly the "should_generate_payload" folder has 12 different valid variations of a docker "FROM" command to ensure the regex used to identify dockerfiles do not exclude any of the samples. As the name of the folder implies all 12 samples should generate a payload ensuring the expected behavior.

  • test/fixtures/negative_dockerfile/
  ├── CW671X02_EBM_EVENT_RULE              (pre-existing test)
  ├── not_dockerfile.debian                                                                                                                                                                                                        
  ├── not_dockerfile.txt
  ├── not_dockerfile.ubi8                                                                                                                                                                                                          
  └── should_not_generate_payload/                                                                                                           
      ├── invalid_syntax                                                                                                                                                                                                           
      ├── negative_email                                                                                                                       
      ├── negative_email_2                                                                                                                                                                                                         
      ├── negative_python
      ├── negative_python_2
      ├── negative_sparql
      └── negative_sql

The .debian and .ubi8 files here should not be flagged as valid dockerfiles since they do not correspond to valid docker configurations. not_dockerfile.txt should not be flagged since, although it contains a valid docker configuration, it has a .txt extension and is not named "dockerfile" (case-insensitive) explicitly — it only contains the word "dockerfile".

The should_not_generate_payload samples test extensionless files containing FROM statements in non-Docker contexts (email header, Python imports, SPARQL queries, SQL) to ensure they are not misidentified as dockerfiles.

These files are used for the util/get_extension unit tests and the new E2E test 106.

As a final note for regarding the tests I should point out that the regex used to identify/exclude samples could never prevent false positives on Files with basic "FROM <any_string>" commands, often related to SQL syntax, in case the files with this text are either:

  • Files without extension
  • Files stored inside the target ("docker/", "dockerfile/" or "dockerfiles/") folders

Moreover a new function, "TestParser_Parse_CaseInsensitive", was added to the parser/docker/parser_test.go unit tests; as the name implies it is meant to ensure docker samples are parsed identically regardless of casing in the dockerfile commands syntax.

I submit this contribution under the Apache-2.0 license.

@cx-andre-pereira
cx-andre-pereira requested a review from a team as a code owner March 11, 2026 22:12
@github-actions github-actions Bot added community Community contribution dockerfile labels Mar 11, 2026
@cx-andre-pereira cx-andre-pereira changed the title Ast 140477 improvement to dockerfile scanning (TEMPORARY PR) fix(analyzer): improvement to dockerfile scanning (TEMPORARY PR) Mar 12, 2026
@cx-andre-pereira cx-andre-pereira changed the title fix(analyzer): improvement to dockerfile scanning (TEMPORARY PR) fix(analyzer): improvement to dockerfile scanning Mar 15, 2026
@github-actions github-actions Bot added docker Docker query query New query feature labels Mar 16, 2026
Comment thread pkg/utils/get_extension.go Outdated

@cx-artur-ribeiro cx-artur-ribeiro left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing to point out besides that.

Comment thread e2e/testcases/e2e-cli-106_valid_dockerfile_detected.go Outdated

@cx-rui-araujo cx-rui-araujo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @cx-andre-pereira, pls check me comments

Comment thread pkg/parser/docker/parser.go
Comment thread pkg/remediation/scan.go Outdated

@cx-artur-ribeiro cx-artur-ribeiro left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, nice job André.

cx-andre-pereira added a commit to cx-andre-pereira/kics that referenced this pull request Apr 16, 2026
cx-andre-pereira added a commit to cx-andre-pereira/kics that referenced this pull request Apr 16, 2026

@cx-rui-araujo cx-rui-araujo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cx-andre-pereira check my comments pls

Comment thread pkg/utils/get_extension.go Outdated
Comment thread pkg/parser/docker/parser.go
cx-rui-araujo
cx-rui-araujo previously approved these changes Apr 21, 2026

@cx-rui-araujo cx-rui-araujo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, nice work @cx-andre-pereira 💪

cx-andre-pereira added a commit to cx-andre-pereira/kics that referenced this pull request Apr 21, 2026
@janderssonse

Copy link
Copy Markdown

This would be great, any hope of seeing it moving along be rebased and move into main?

…es and all files with prefix 'dockerfile.' as well as all files with the '.dockerfile' extension type in a case insensitive matter (improvement on first commit)
…sion, added support for all ubi8/debian files in case of valid dockerfile structure, added support for lower case dockerfile commands - most queries will have issues with this but relevant text files are properly detected as a 'dockerfile' as intended
…rors, fixed 'gitignore' files exclusion, docker parser will handle said case like before but with explicit 'gitignore' extension rather than 'possibleDockerfile' like before
…sion so that it 1- gets detected regardless of syntax inside 2- gets detected withouth checking syntax inside through the code optimizing detection speed for said files
…wice and minor simplificaton of query arguments
cx-andre-pereira added a commit to cx-andre-pereira/kics that referenced this pull request Jul 8, 2026
@cx-andre-pereira
cx-andre-pereira force-pushed the AST-140477--Improvement-to-dockerfile-scanning branch 2 times, most recently from 3d99baf to 0b9ac2b Compare July 28, 2026 14:03
cx-andre-pereira added a commit to cx-andre-pereira/kics that referenced this pull request Jul 28, 2026
…oid stepsecurity cancel)

Reverts workflow changes from 1c695d0 and 48e6848. The fix NPM_CONFIG_REGISTRY=https://registry.npmjs.org for lockfile-lint will be landed via a separate PR from a branch on Checkmarx/kics itself. This keeps the analyzer collectFiles fix (735c067) in this fork PR without triggering 'canceled forcefully by @stepsecurity-app[bot]' approval gate.
@cx-andre-pereira
cx-andre-pereira deleted the AST-140477--Improvement-to-dockerfile-scanning branch September 8, 2026 15:19
cx-artur-ribeiro added a commit that referenced this pull request Sep 17, 2026
…rt of dockerfile commands (#8115)

* fix(query): fix EFS Volume With Disabled Transit Encryption queries for multiple volumes cases (#7947)

* fix EFS Volume With Disabled Transit Encryption query for multiple volumes cases in tf and cf

* update: dockerfile images

* fix(analyzer): add failed utf conversions to unwanted files (#7997)

* add bad utf conversions to unwanted in analyzer

* add bad utf conversions to unwanted in analyzer

* update e2e tests and uts to cover valid ansible samples

* update base images

---------

Co-authored-by: cx-miguel-silva <100352574+cx-miguel-silva@users.noreply.github.com>

* Upgrade Trivy action to version 0.35.0

Updated Trivy action version from v0.34.2 to v0.35.0 in both scanning steps.

* fix(dockerhub): add token login to DockerHub (#8024)

* update: login to DockerHub to token

* bump: kics github action version

* feat(testing): add arm64 testing infra (#7998)

* add arm64 testing infra

* add arm64 testing infra

* bump images

* ci

* update e2e infra

* update e2e infra

* improve docker ubi 8 to support arm

* improve docker ubi 8 to support arm

* improve docker ubi 8 to support arm

* improve docker ubi 8 to support arm

* fix vulnerabilities

* fix vulnerabilities

* fix vulnerabilities

* fix vulnerabilities

* fix vulnerabilities

---------

Co-authored-by: cx-miguel-silva <100352574+cx-miguel-silva@users.noreply.github.com>
Co-authored-by: Artur Ribeiro <153724638+cx-artur-ribeiro@users.noreply.github.com>

* feat(tests): improving E2E HTML report and output on remediation tests (#7955)

* first commit

* rewrite previous changes

* causing remediation error on purpose

* some changes

* .

* .

* added remediatedFiles to error output in remediation tests

* restored directories removed by mistake

* removed files

* Delete assets/queries/terraform/aws/api_gateway_access_logging_disabled/payloads/all_payloads.json

* Delete assets/queries/terraform/aws/sns_topic_is_publicly_accessible/payloads/all_payloads.json

* Delete assets/queries/terraform/aws/sns_topic_is_publicly_accessible/payloads directory

* Delete assets/queries/terraform/aws/sns_topic_is_publicly_accessible/samples/sample.tf

* Delete assets/queries/terraform/gcp/ensure_essential_contacts_is_configured_for_organization/payloads/all_payloads.json

* Delete assets/queries/terraform/gcp/ensure_essential_contacts_is_configured_for_organization/payloads directory

* Delete assets/queries/terraform/gcp/ensure_gke_version_management_is_automated_using_release_channels/payloads/all_payloads.json

* Delete assets/queries/terraform/gcp/ensure_gke_version_management_is_automated_using_release_channels/payloads directory

* Delete assets/queries/terraform/gcp/google_kubernetes_engine_cluster_have_alpha_features_enabled/payloads/all_payloads.json

* Delete assets/queries/terraform/gcp/legacy_networks_do_not_exist_for_older_google_projects/payloads/test_payload.json

* Delete assets/queries/terraform/gcp/legacy_networks_do_not_exist_for_older_google_projects/payloads directory

* Delete assets/queries/terraform/gcp/logs_and_alerts_missing_audit_configuration_changes/payloads/all_payloads.json

* Delete assets/queries/terraform/gcp/logs_and_alerts_missing_audit_configuration_changes/payloads directory

* Delete assets/queries/terraform/gcp/logs_and_alerts_missing_custom_role_changes/test/test.tf

* Delete assets/queries/terraform/gcp/logs_and_alerts_missing_custom_role_changes/payloads directory

* Delete assets/queries/terraform/gcp/logs_and_alerts_missing_project_ownership_assignment_and_changes/payloads/positive1_payload.json

* Delete assets/queries/terraform/gcp/logs_and_alerts_missing_project_ownership_assignment_and_changes/payloads directory

* Delete assets/queries/terraform/gcp/shielded_gke_node_do_not_have_integrity_monitoring_enabled/payloads/all_payloads.json

* Delete assets/queries/terraform/gcp/shielded_gke_node_do_not_have_integrity_monitoring_enabled/payloads directory

* Delete assets/queries/terraform/gcp/sql_db_instance_external_scripts_enabled/test/negative.tf

* Delete assets/queries/terraform/gcp/sql_db_instance_external_scripts_enabled/test directory

* Delete assets/queries/terraform/gcp/sql_db_instance_external_scripts_enabled directory

* added remediation problems to the query

* fixed golint problems

* golint

* change on the query

* fixing line that surpasses the 140 characters limits by go-ci/lint

* .

* changed e2e test to see HTML results output

* .

* .

* .

* removed one query in the results

* indenting json output on E2E test HTML report

* changed fixture results

* changed comparison using listA and list B, to Expected and Actual lists

* some changes on the json output

* reverted changes on E2E results outputs

* put listA and listB side by side

* fully implemented red line for diff line

* added queryName in the output

* final improvement on HTML E2E test results output

* removed unnecessary comment

* revert changes made on E2E fixtures

* reverted changes on E2E files

* reverted changes on E2E files

* reverted changes on the wrong go template file

* fixing go lint errors

* fixing go lint error

* go lint error fixing

* go lint error fixing

* go lint error fixing

* fixing go lint errors

* fixing go lint errors

* fixing go lint errors

* fixing go lint errors

* fixing go lint errors

* fixing go lint errors

* keeping up with the codacy quality standards

* improvements on the code

* trimmed lines before direct comparisons

* adding the e2e-report file again

* changing google.golang.org/grpc version from 1.77.0 to 1.79.3

* fixed analyze command in e2e test

* covered FileStats field comparison on e2e tests

* reverting changes made on analyze.go file

* changed moby/buildkit version from 0.26.3 to 0.28.1

* revert changes

* changed moby/buildkit version from 0.26.3 to 0.28.1

* fixing unproperly formatted code

* fixed path

* fixed unproperly formatted code

* removed commented code

* fixed some E2E tests not showing the intended output format

* final fix for the tests that are currently without the proper HTML report output format

* changing code to reduce cyclomatic complexity

* fixing code to be properly formatted

* removed unnecessary printf's

* fixing the code using gofmt

* changed github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream and github.com/aws/aws-sdk-go-v2/service/s3 version in go.mod

---------

Co-authored-by: Artur Ribeiro <153724638+cx-artur-ribeiro@users.noreply.github.com>

* fix(workflows): update github actions to use SHA (#8035)

* Update github action to use SHA

* Update vulnerable dependency

* Update dockerfiles to use go 1.26.2

* Rollback go.mod to 1.25.5

* Fix vulnerabilities

* Fix vulnerabilities

* Update go version

* Suppress vulnerability

* Update dockerfile

* Update .grype.yaml

Co-authored-by: Rui Araújo Gomes <110477212+cx-rui-araujo@users.noreply.github.com>

* Small update

---------

Co-authored-by: Rui Araújo Gomes <110477212+cx-rui-araujo@users.noreply.github.com>

* feat(action): added validation for searchLine field in actions (#7994)

* changed go-ci.yml to use a script to check searchLine

* .

* fixed print to not use f when is missing placeholders

* removed unnecessary action

* fixed typo

* fixing issues from codacy

* updated go image in Dockerfile

* update go images

* changed git image

* changing positive expected results

* added requests to requirements file

* changed searchLine to get -1 value

* added debug prints

* added exception type

* fixing error in script

* removed trailing whitespace

* changed to run the other script

* debugging test directory path

* changed scripts that run on the action

* removed f-string without placeholders

* inverted changes on the query

* changed positive_expected_result

* changed filename to fileName

* added print for debugging processes

* added print to see content value

* changed script

* testing searchLine != searchLine

* removed unnecessary sorting on the results in execution context

* removed unused requirements.txt file

* reverter changes on positie_expected_results

* changes on the script and removed unnecessary go setup

* changed query to get errors on go-ci action

* parsing json data into objects

* small change to test if this is the root of the problem

* reverted changes

* fixing misspelled directory name

* fixing some errors in the script used in the validate-search-line job in go-ci action

* fixed misspelled field in validate_scan_results function

* simplifying code

* using pymarshal to use models that unmarshal json content directly

* fixing errors in results_models pymarshal import

* testing searchLine defined to '-1' hardcoded value

* convert line and searchLine to int

* adding print's for debug purposes

* adding print's for debug purposes

* fixing cases where searchLine is defined to an hardcoded value of -1

* added prints for debug purposes

* debug prints

* debug prints

* debug prints

* changes for debug purposes

* .

* changes

* trying to fix cases with -1 hardcoded on searchLine

* changes

* more changes

* trying type_assert

* trying type_assert

* trying type_assert

* trying type_assert

* trying type_assert

* testing new scenario

* testing test3 case from artur test branch

* testing test3 case from artur test branch

* back to the other scenario

* back to the other scenario again

* used unmarshal_json from pumarshal to unmarshal the json with the results

* testing hardcoded .1 again

* trying case - common_lib.build_search_line([shdfosdhfoisdhf], []),

* reverting changes on dockerfiles

* removed the usage of type_assert to be more permissive about fields not defined on the results file

* changed to see other case output in the actions

* added field queries_failed_to_execute

* changing query searchLine field to test another scenario

* changed to another scenario

* reverting changes made on the query

* changed to test scenario when "searchLine": common_lib.build_search_line(["potatos"], [])

* testing scenario where searchLine is defined to '-1'

* removed unnecessary pymarshal pip instalation

* testing another scenario

* testing searchLine defined to '-1'

* testing searchLine defined to 'potatos'

* reverting query changezs

* reverting changes on query

* reverting changes on docker files

* reverting changes on dockerfiles

* removed \n

* adding debug prints to see the output from variables produced by dorny/path

* added \n

* added echo for debug purposes

* Reverting changes on Dockerfile

* adding print on script

* testing outcome

* using Set Up python step outcome value to define if validate search line in modified queries runs or not

* changing go-jose version

* changing script code to match Codacy best practices

* changing code to comply with the Codacy quality standards

* changing go.mod

* fixing Codacy issues

* changing Go and Git images on Dockerfile

* changing go.mod

* reverting changes on go.mod

* changing go version

* fixing scripts according to Codacy issues

* fixing script to be up to the Codacy quality standards

* fixing Codacy issues

* fixing Codacy issues

* fixing Codacy issues

* fixing D212 in validate_search_line.py file

* reverting changes to fix D212

---------

Co-authored-by: Artur Ribeiro <153724638+cx-artur-ribeiro@users.noreply.github.com>

* Change to use actions role (#8040)

* Change to use actions role

* Update run-projects.yaml

* ci(secrets): use aws oidc (#8041)

* ci: fix aws secrets

* ci: fix permissions

* ci: remove audience

* ci: test gh token

* ci: use sha

* fix(query): fix FP results on "IAM policy allows for data exfiltration" CloudFormation and Terraform queries (#8030)

* Added missing check/associated tests to cloudFormation and Terraform iam_policy data exfiltration queries

---------

Co-authored-by: Artur Ribeiro <153724638+cx-artur-ribeiro@users.noreply.github.com>

* [StepSecurity] Apply security best practices (#8060)

Signed-off-by: StepSecurity Bot <bot@stepsecurity.io>
Co-authored-by: stepsecurity-app[bot] <188008098+stepsecurity-app[bot]@users.noreply.github.com>

* [StepSecurity] Apply security best practices (#8063)

Signed-off-by: StepSecurity Bot <bot@stepsecurity.io>
Co-authored-by: stepsecurity-app[bot] <188008098+stepsecurity-app[bot]@users.noreply.github.com>

* chore: remove Dependabot configuration

* Remove old SBOM (#8071)

Signed-off-by: Yevgeny Kuznetsov <yevgeny.kuznetsov@checkmarx.com>

* fix(vulnerabilities): update dockerfile and fix trivy vulnerabilities (#8076)

* update: dockerfile and fix vulnerabilities

* update: dockerfile with arguments before both FROM for universal scope

* update: vulnerable packages and dockerfile images

* ci: trigger

* fix: dockerfile deprecation notice for LegacyKeyValueFormat

* First tests

* First commit with changes to all dockerfile queries for case insesitivity support + tests

* Fixes for queries that require extra commands and some expected results fixed

* Small fix to update instruction alone query

* Test changes for payload compatibility

* Testings possible fix for parsing issue (multiple From statements)

* Removed needless check

* Fixes

* Mini fix for linting

* Added id to distinguish repeated FROM statements on the same image (lower query overhead)

* Linting fix 2

* Best of both worlds solution, fallback to the implementation that changes searchKey but now only changes if warranted, simplified distinction between identical FROM statements in the payload with a Endline-1 in brackets, SimId will vary if lines shift (exclusively on duplicate FROM statements that flag)

* slight changes to query

* SimID now depends on number of duplicate FROM statements prior to the one being evaluared, searchKey include number of duplicate and linehint (as before) in that order, latter is extracted before simID calculation

* If it is decided that altered image name can be kept queries can stay simplified since the simID will be distict already

* Revert accidental line change in positive3

* Small fix unit test

* SearchKey values in results are now sanitized of extra ^hintLine added, the value is used for search purposes and then stripped

* Moved auxiliary functions to common library and adjusted all queries to use the lineHint, added new E2E test on new multistage sample (note test is 107 because 106 should be added by another PR)

* Files that should have been in previous commit

* Fix E2E testcase

* Adjusted expected results for same alias in different forms query

* E2E fixture fix and typo fix

* Unit test to ensure line hint is being used on docker_detect

* Added unit test to docker parser to ensure duplicate FROMs are distinct commands in payload

* Added unit test to vulnerability builder to ensure line hint is removed from searchKey

* Changed identification of docker files to be case insensitive on files named 'dockerfile'

* removed legacy redundant function 'isDockerfile' from analyzer

* Improved dockerfile identification to account for relevant folder names and all files with prefix 'dockerfile.' as well as all files with the '.dockerfile' extension type in a case insensitive matter (improvement on first commit)

* Fixed 'dockerfile' keyword not being recognized as a valid file extension, added support for all ubi8/debian files in case of valid dockerfile structure, added support for lower case dockerfile commands - most queries will have issues with this but relevant text files are properly detected as a 'dockerfile' as intended

* Minor optimization

* Initial test files/cases plus minor changes to supported dockerfile formats for consistency

* Added new helper function 'isDockerfileExtension' to get_extension utility to lower cyclomatic complexity

* reverted accidental query change, fixed linting errors, fixed test errors, fixed 'gitignore' files exclusion, docker parser will handle said case like before but with explicit 'gitignore' extension rather than 'possibleDockerfile' like before

* linting fix and optimized case of file named dockerfile without extension so that it 1- gets detected regardless of syntax inside 2- gets detected withouth checking syntax inside through the code optimizing detection speed for said files

* More changes to fix go lint, d variable so 'dockerfile' is not used twice and minor simplificaton of query arguments

* Added samples for case insensitive testing on dockerfiles, added E2E test 105, improved uni tests to include new case insensitive samples

* fix for E2E

* Changed relevant functions to always treat/set the extension of valid dockerfiles as '.dockerfile'

* Removed last mention of 'dockerfile' without dot notation

* Changed 'gitignore' check for better check order in 'GetExtension' function

* Slightly more restrictive check to FROM command to ensure it has a trailing whitespace

* Updates to functions, removed unnecessary if statement on scan.go and unnecessary 'gitignore' case in analyzer's workers

* fix previous commit

* fix analyzer uni tests

* simplified new if condition

* lint fix

* fixed analyze unit tests, with names ending in 'gitignore' no longer have to be explicitly set as unwanted to allign with '.gitignore' behaviour

* Case-insensitive unit tests for dockerfile samples

* Slight changes to new test

* Slight simplification of new docker/parser unit test

* Mini fix on insensitive_sample

* Changed E2E to 106 to fix merge conflict

* fix E2E tests

* Final E2E fix

* Update to 'Docker' related documentation

* Requested change - made extDockerfile a constant

* Fixed E2E 106 fixture 'RESULT' file name

* Refactor to 'get_extension' and 'analyzer' to reduce redudancy

* Lint error fix

* Newline removed (lint)

* Renamed variable to prevent confusing shadowing

* Requested E2E change

* Removed .ubi8 and .debian extensions checks

* Fallback on debian and ubi removal from docker/parser to test E2E

* E2E test 2

* New 'python' samples to test for edge case 'from' statements on files without extension or within docker folder, adjusted readPossibleDockerfile to an improved regex based logic, adjusted file.Dockerfile to test for whitespaces before a from statement

* New samples and improved, tailored regex for dockerfile FROM statement identification - E2E test should break

* Removed duplicated sample(negative) that was in positive test fixture dockerfile folder, updated E2E results

* Final fix for E2E plus the test file removal that should have been in previous commit

* Updates E2E fixtures

* First fix attempt on validate-search-line script

* Removed need to do -1 when calling line hint function and updated documentation to reflect specific dockerfile searchKey building

* Fixed expected and actual values for using_platform_with_from query

* Fix E2E results

* Made UrlRegex a constant

* New samples, changed fockerfile syntax identification to aproach to exclusion based regex

* Linter fix

* The actual linter fix

* Fixed dokcerfile lib from statement function LineHint value so multiline FROM statements are compatible, fixed whitespace support for ARG/comments in dockerfiles and fix new E2E results

* Fix E2E 107

* First tests

* First commit with changes to all dockerfile queries for case insesitivity support + tests

* Fixes for queries that require extra commands and some expected results fixed

* Small fix to update instruction alone query

* Test changes for payload compatibility

* Testings possible fix for parsing issue (multiple From statements)

* Removed needless check

* Fixes

* Mini fix for linting

* Added id to distinguish repeated FROM statements on the same image (lower query overhead)

* Linting fix 2

* Best of both worlds solution, fallback to the implementation that changes searchKey but now only changes if warranted, simplified distinction between identical FROM statements in the payload with a Endline-1 in brackets, SimId will vary if lines shift (exclusively on duplicate FROM statements that flag)

* slight changes to query

* SimID now depends on number of duplicate FROM statements prior to the one being evaluared, searchKey include number of duplicate and linehint (as before) in that order, latter is extracted before simID calculation

* If it is decided that altered image name can be kept queries can stay simplified since the simID will be distict already

* Revert accidental line change in positive3

* Small fix unit test

* SearchKey values in results are now sanitized of extra ^hintLine added, the value is used for search purposes and then stripped

* Moved auxiliary functions to common library and adjusted all queries to use the lineHint, added new E2E test on new multistage sample (note test is 107 because 106 should be added by another PR)

* Files that should have been in previous commit

* Fix E2E testcase

* Adjusted expected results for same alias in different forms query

* E2E fixture fix and typo fix

* Unit test to ensure line hint is being used on docker_detect

* Added unit test to docker parser to ensure duplicate FROMs are distinct commands in payload

* Added unit test to vulnerability builder to ensure line hint is removed from searchKey

* Changed identification of docker files to be case insensitive on files named 'dockerfile'

* removed legacy redundant function 'isDockerfile' from analyzer

* Improved dockerfile identification to account for relevant folder names and all files with prefix 'dockerfile.' as well as all files with the '.dockerfile' extension type in a case insensitive matter (improvement on first commit)

* Fixed 'dockerfile' keyword not being recognized as a valid file extension, added support for all ubi8/debian files in case of valid dockerfile structure, added support for lower case dockerfile commands - most queries will have issues with this but relevant text files are properly detected as a 'dockerfile' as intended

* Minor optimization

* Initial test files/cases plus minor changes to supported dockerfile formats for consistency

* Added new helper function 'isDockerfileExtension' to get_extension utility to lower cyclomatic complexity

* reverted accidental query change, fixed linting errors, fixed test errors, fixed 'gitignore' files exclusion, docker parser will handle said case like before but with explicit 'gitignore' extension rather than 'possibleDockerfile' like before

* linting fix and optimized case of file named dockerfile without extension so that it 1- gets detected regardless of syntax inside 2- gets detected withouth checking syntax inside through the code optimizing detection speed for said files

* More changes to fix go lint, d variable so 'dockerfile' is not used twice and minor simplificaton of query arguments

* Added samples for case insensitive testing on dockerfiles, added E2E test 105, improved uni tests to include new case insensitive samples

* fix for E2E

* Changed relevant functions to always treat/set the extension of valid dockerfiles as '.dockerfile'

* Removed last mention of 'dockerfile' without dot notation

* Changed 'gitignore' check for better check order in 'GetExtension' function

* Slightly more restrictive check to FROM command to ensure it has a trailing whitespace

* Updates to functions, removed unnecessary if statement on scan.go and unnecessary 'gitignore' case in analyzer's workers

* fix previous commit

* fix analyzer uni tests

* simplified new if condition

* lint fix

* fixed analyze unit tests, with names ending in 'gitignore' no longer have to be explicitly set as unwanted to allign with '.gitignore' behaviour

* Case-insensitive unit tests for dockerfile samples

* Slight changes to new test

* Slight simplification of new docker/parser unit test

* Mini fix on insensitive_sample

* Changed E2E to 106 to fix merge conflict

* fix E2E tests

* Final E2E fix

* Update to 'Docker' related documentation

* Requested change - made extDockerfile a constant

* Fixed E2E 106 fixture 'RESULT' file name

* Refactor to 'get_extension' and 'analyzer' to reduce redudancy

* Lint error fix

* Newline removed (lint)

* Renamed variable to prevent confusing shadowing

* Requested E2E change

* Removed .ubi8 and .debian extensions checks

* Fallback on debian and ubi removal from docker/parser to test E2E

* E2E test 2

* Final fix E2E, the E2E itself was incorrect, payload included invalid .debian and .ubi8 files since they were still considered supported even though now .dockerfile is the only valid dockerfile extension resulting from the 'GetExtension' function

* New 'python' samples to test for edge case 'from' statements on files without extension or within docker folder, adjusted readPossibleDockerfile to an improved regex based logic, adjusted file.Dockerfile to test for whitespaces before a from statement

* New samples and improved, tailored regex for dockerfile FROM statement identification - E2E test should break

* Removed duplicated sample(negative) that was in positive test fixture dockerfile folder, updated E2E results

* Final fix for E2E plus the test file removal that should have been in previous commit

* Fix previous merge with #7995

* Updates E2E fixtures

* First fix attempt on validate-search-line script

* Removed need to do -1 when calling line hint function and updated documentation to reflect specific dockerfile searchKey building

* Fixed expected and actual values for using_platform_with_from query

* Fix E2E results

* Made UrlRegex a constant

* New samples, changed fockerfile syntax identification to aproach to exclusion based regex

* Linter fix

* The actual linter fix

* E2E fix

* Fixed dokcerfile lib from statement function LineHint value so multiline FROM statements are compatible, fixed whitespace support for ARG/comments in dockerfiles and fix new E2E results

* Fix E2E 107

* fix changed files to pre-rebase state

* Fixed value attribution that should have been comparison

* bug(security): fix security vulnerability findings (#8084)

* fix insecure temp file

* fix insecure temp file perms

* add path traversal sanitation

* add path traversal sanitization

* add path traversal sanitization tests

* add path traversal sanitization e2e tests

* add path traversal sanitization e2e tests

* fix lint issues

* fix secrets inspector possible resource exhaustion

* fix secrets line detection for end of document specific case

* bump deps and actions versions

* bump deps and actions versions

* [StepSecurity] Apply security best practices (#8060)

Signed-off-by: StepSecurity Bot <bot@stepsecurity.io>
Co-authored-by: stepsecurity-app[bot] <188008098+stepsecurity-app[bot]@users.noreply.github.com>

* [StepSecurity] Apply security best practices (#8063)

Signed-off-by: StepSecurity Bot <bot@stepsecurity.io>
Co-authored-by: stepsecurity-app[bot] <188008098+stepsecurity-app[bot]@users.noreply.github.com>

* chore: remove Dependabot configuration

* Remove old SBOM (#8071)

Signed-off-by: Yevgeny Kuznetsov <yevgeny.kuznetsov@checkmarx.com>

* fix(vulnerabilities): update dockerfile and fix trivy vulnerabilities (#8076)

* update: dockerfile and fix vulnerabilities

* update: dockerfile with arguments before both FROM for universal scope

* update: vulnerable packages and dockerfile images

* ci: trigger

* fix: dockerfile deprecation notice for LegacyKeyValueFormat

---------

Signed-off-by: StepSecurity Bot <bot@stepsecurity.io>
Signed-off-by: Yevgeny Kuznetsov <yevgeny.kuznetsov@checkmarx.com>
Co-authored-by: cx-miguel-silva <100352574+cx-miguel-silva@users.noreply.github.com>
Co-authored-by: stepsecurity-app[bot] <188008098+stepsecurity-app[bot]@users.noreply.github.com>
Co-authored-by: Ohad Israeli <243351248+cx-ohad-israeli@users.noreply.github.com>
Co-authored-by: Yevgeny Kuznetsov <yevgeny.kuznetsov@checkmarx.com>
Co-authored-by: Artur Ribeiro <153724638+cx-artur-ribeiro@users.noreply.github.com>

* fix(parser): fixed looping behavior triggered during dockerfile parsing  (#8085)

* fixs for ast 154904, loop on RUN commands and 2 unrelated queries changed

* Fixed unnecessary space affecting distance calculation/ line in vulnerability result

* Update packages again

* fix(query): updated "SQL DB Instance With SSL Disabled" Terraform query to handle 'require_ssl' field deprecation  (#8029)

* First commit: udpated query to handle deprecation of 'require_ssl' field, support for all 'ssl_mode' field values, new tests and metadata Url updated

* Small change to comments for consistency sake

* New samples and auxiliary functions to properly handle SQLSERVER databases (do not support 'TRUSTED_CLIENT_CERTIFICATE_REQUIRED' value

* Expected values and some test changes

* Fix expected results again

---------

Co-authored-by: Alon Rosenhek <80337069+cx-alon-rosenhek@users.noreply.github.com>

* fix(query): the "Image Version Using Latest" dockerfile query was not accounting for specific digest values (#8033)

* Fix check for ':latest' to ensure it is used as a sufix on the image reference (no @sha...)

* feat(tests): improving E2E HTML report and output on remediation tests (#7955)

* first commit

* rewrite previous changes

* causing remediation error on purpose

* some changes

* .

* .

* added remediatedFiles to error output in remediation tests

* restored directories removed by mistake

* removed files

* Delete assets/queries/terraform/aws/api_gateway_access_logging_disabled/payloads/all_payloads.json

* Delete assets/queries/terraform/aws/sns_topic_is_publicly_accessible/payloads/all_payloads.json

* Delete assets/queries/terraform/aws/sns_topic_is_publicly_accessible/payloads directory

* Delete assets/queries/terraform/aws/sns_topic_is_publicly_accessible/samples/sample.tf

* Delete assets/queries/terraform/gcp/ensure_essential_contacts_is_configured_for_organization/payloads/all_payloads.json

* Delete assets/queries/terraform/gcp/ensure_essential_contacts_is_configured_for_organization/payloads directory

* Delete assets/queries/terraform/gcp/ensure_gke_version_management_is_automated_using_release_channels/payloads/all_payloads.json

* Delete assets/queries/terraform/gcp/ensure_gke_version_management_is_automated_using_release_channels/payloads directory

* Delete assets/queries/terraform/gcp/google_kubernetes_engine_cluster_have_alpha_features_enabled/payloads/all_payloads.json

* Delete assets/queries/terraform/gcp/legacy_networks_do_not_exist_for_older_google_projects/payloads/test_payload.json

* Delete assets/queries/terraform/gcp/legacy_networks_do_not_exist_for_older_google_projects/payloads directory

* Delete assets/queries/terraform/gcp/logs_and_alerts_missing_audit_configuration_changes/payloads/all_payloads.json

* Delete assets/queries/terraform/gcp/logs_and_alerts_missing_audit_configuration_changes/payloads directory

* Delete assets/queries/terraform/gcp/logs_and_alerts_missing_custom_role_changes/test/test.tf

* Delete assets/queries/terraform/gcp/logs_and_alerts_missing_custom_role_changes/payloads directory

* Delete assets/queries/terraform/gcp/logs_and_alerts_missing_project_ownership_assignment_and_changes/payloads/positive1_payload.json

* Delete assets/queries/terraform/gcp/logs_and_alerts_missing_project_ownership_assignment_and_changes/payloads directory

* Delete assets/queries/terraform/gcp/shielded_gke_node_do_not_have_integrity_monitoring_enabled/payloads/all_payloads.json

* Delete assets/queries/terraform/gcp/shielded_gke_node_do_not_have_integrity_monitoring_enabled/payloads directory

* Delete assets/queries/terraform/gcp/sql_db_instance_external_scripts_enabled/test/negative.tf

* Delete assets/queries/terraform/gcp/sql_db_instance_external_scripts_enabled/test directory

* Delete assets/queries/terraform/gcp/sql_db_instance_external_scripts_enabled directory

* added remediation problems to the query

* fixed golint problems

* golint

* change on the query

* fixing line that surpasses the 140 characters limits by go-ci/lint

* .

* changed e2e test to see HTML results output

* .

* .

* .

* removed one query in the results

* indenting json output on E2E test HTML report

* changed fixture results

* changed comparison using listA and list B, to Expected and Actual lists

* some changes on the json output

* reverted changes on E2E results outputs

* put listA and listB side by side

* fully implemented red line for diff line

* added queryName in the output

* final improvement on HTML E2E test results output

* removed unnecessary comment

* revert changes made on E2E fixtures

* reverted changes on E2E files

* reverted changes on E2E files

* reverted changes on the wrong go template file

* fixing go lint errors

* fixing go lint error

* go lint error fixing

* go lint error fixing

* go lint error fixing

* fixing go lint errors

* fixing go lint errors

* fixing go lint errors

* fixing go lint errors

* fixing go lint errors

* fixing go lint errors

* keeping up with the codacy quality standards

* improvements on the code

* trimmed lines before direct comparisons

* adding the e2e-report file again

* changing google.golang.org/grpc version from 1.77.0 to 1.79.3

* fixed analyze command in e2e test

* covered FileStats field comparison on e2e tests

* reverting changes made on analyze.go file

* changed moby/buildkit version from 0.26.3 to 0.28.1

* revert changes

* changed moby/buildkit version from 0.26.3 to 0.28.1

* fixing unproperly formatted code

* fixed path

* fixed unproperly formatted code

* removed commented code

* fixed some E2E tests not showing the intended output format

* final fix for the tests that are currently without the proper HTML report output format

* changing code to reduce cyclomatic complexity

* fixing code to be properly formatted

* removed unnecessary printf's

* fixing the code using gofmt

* changed github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream and github.com/aws/aws-sdk-go-v2/service/s3 version in go.mod

---------

Co-authored-by: Artur Ribeiro <153724638+cx-artur-ribeiro@users.noreply.github.com>

* fix(workflows): update github actions to use SHA (#8035)

* Update github action to use SHA

* Update vulnerable dependency

* Update dockerfiles to use go 1.26.2

* Rollback go.mod to 1.25.5

* Fix vulnerabilities

* Fix vulnerabilities

* Update go version

* Suppress vulnerability

* Update dockerfile

* Update .grype.yaml

Co-authored-by: Rui Araújo Gomes <110477212+cx-rui-araujo@users.noreply.github.com>

* Small update

---------

Co-authored-by: Rui Araújo Gomes <110477212+cx-rui-araujo@users.noreply.github.com>

* feat(action): added validation for searchLine field in actions (#7994)

* changed go-ci.yml to use a script to check searchLine

* .

* fixed print to not use f when is missing placeholders

* removed unnecessary action

* fixed typo

* fixing issues from codacy

* updated go image in Dockerfile

* update go images

* changed git image

* changing positive expected results

* added requests to requirements file

* changed searchLine to get -1 value

* added debug prints

* added exception type

* fixing error in script

* removed trailing whitespace

* changed to run the other script

* debugging test directory path

* changed scripts that run on the action

* removed f-string without placeholders

* inverted changes on the query

* changed positive_expected_result

* changed filename to fileName

* added print for debugging processes

* added print to see content value

* changed script

* testing searchLine != searchLine

* removed unnecessary sorting on the results in execution context

* removed unused requirements.txt file

* reverter changes on positie_expected_results

* changes on the script and removed unnecessary go setup

* changed query to get errors on go-ci action

* parsing json data into objects

* small change to test if this is the root of the problem

* reverted changes

* fixing misspelled directory name

* fixing some errors in the script used in the validate-search-line job in go-ci action

* fixed misspelled field in validate_scan_results function

* simplifying code

* using pymarshal to use models that unmarshal json content directly

* fixing errors in results_models pymarshal import

* testing searchLine defined to '-1' hardcoded value

* convert line and searchLine to int

* adding print's for debug purposes

* adding print's for debug purposes

* fixing cases where searchLine is defined to an hardcoded value of -1

* added prints for debug purposes

* debug prints

* debug prints

* debug prints

* changes for debug purposes

* .

* changes

* trying to fix cases with -1 hardcoded on searchLine

* changes

* more changes

* trying type_assert

* trying type_assert

* trying type_assert

* trying type_assert

* trying type_assert

* testing new scenario

* testing test3 case from artur test branch

* testing test3 case from artur test branch

* back to the other scenario

* back to the other scenario again

* used unmarshal_json from pumarshal to unmarshal the json with the results

* testing hardcoded .1 again

* trying case - common_lib.build_search_line([shdfosdhfoisdhf], []),

* reverting changes on dockerfiles

* removed the usage of type_assert to be more permissive about fields not defined on the results file

* changed to see other case output in the actions

* added field queries_failed_to_execute

* changing query searchLine field to test another scenario

* changed to another scenario

* reverting changes made on the query

* changed to test scenario when "searchLine": common_lib.build_search_line(["potatos"], [])

* testing scenario where searchLine is defined to '-1'

* removed unnecessary pymarshal pip instalation

* testing another scenario

* testing searchLine defined to '-1'

* testing searchLine defined to 'potatos'

* reverting query changezs

* reverting changes on query

* reverting changes on docker files

* reverting changes on dockerfiles

* removed \n

* adding debug prints to see the output from variables produced by dorny/path

* added \n

* added echo for debug purposes

* Reverting changes on Dockerfile

* adding print on script

* testing outcome

* using Set Up python step outcome value to define if validate search line in modified queries runs or not

* changing go-jose version

* changing script code to match Codacy best practices

* changing code to comply with the Codacy quality standards

* changing go.mod

* fixing Codacy issues

* changing Go and Git images on Dockerfile

* changing go.mod

* reverting changes on go.mod

* changing go version

* fixing scripts according to Codacy issues

* fixing script to be up to the Codacy quality standards

* fixing Codacy issues

* fixing Codacy issues

* fixing Codacy issues

* fixing D212 in validate_search_line.py file

* reverting changes to fix D212

---------

Co-authored-by: Artur Ribeiro <153724638+cx-artur-ribeiro@users.noreply.github.com>

* Change to use actions role (#8040)

* Change to use actions role

* Update run-projects.yaml

* ci(secrets): use aws oidc (#8041)

* ci: fix aws secrets

* ci: fix permissions

* ci: remove audience

* ci: test gh token

* ci: use sha

* fix(query): fix FP results on "IAM policy allows for data exfiltration" CloudFormation and Terraform queries (#8030)

* Added missing check/associated tests to cloudFormation and Terraform iam_policy data exfiltration queries

---------

Co-authored-by: Artur Ribeiro <153724638+cx-artur-ribeiro@users.noreply.github.com>

* [StepSecurity] Apply security best practices (#8060)

Signed-off-by: StepSecurity Bot <bot@stepsecurity.io>
Co-authored-by: stepsecurity-app[bot] <188008098+stepsecurity-app[bot]@users.noreply.github.com>

* [StepSecurity] Apply security best practices (#8063)

Signed-off-by: StepSecurity Bot <bot@stepsecurity.io>
Co-authored-by: stepsecurity-app[bot] <188008098+stepsecurity-app[bot]@users.noreply.github.com>

* chore: remove Dependabot configuration

* Remove old SBOM (#8071)

Signed-off-by: Yevgeny Kuznetsov <yevgeny.kuznetsov@checkmarx.com>

* fix(vulnerabilities): update dockerfile and fix trivy vulnerabilities (#8076)

* update: dockerfile and fix vulnerabilities

* update: dockerfile with arguments before both FROM for universal scope

* update: vulnerable packages and dockerfile images

* ci: trigger

* fix: dockerfile deprecation notice for LegacyKeyValueFormat

* bug(security): fix security vulnerability findings (#8084)

* fix insecure temp file

* fix insecure temp file perms

* add path traversal sanitation

* add path traversal sanitization

* add path traversal sanitization tests

* add path traversal sanitization e2e tests

* add path traversal sanitization e2e tests

* fix lint issues

* fix secrets inspector possible resource exhaustion

* fix secrets line detection for end of document specific case

* bump deps and actions versions

* bump deps and actions versions

* [StepSecurity] Apply security best practices (#8060)

Signed-off-by: StepSecurity Bot <bot@stepsecurity.io>
Co-authored-by: stepsecurity-app[bot] <188008098+stepsecurity-app[bot]@users.noreply.github.com>

* [StepSecurity] Apply security best practices (#8063)

Signed-off-by: StepSecurity Bot <bot@stepsecurity.io>
Co-authored-by: stepsecurity-app[bot] <188008098+stepsecurity-app[bot]@users.noreply.github.com>

* chore: remove Dependabot configuration

* Remove old SBOM (#8071)

Signed-off-by: Yevgeny Kuznetsov <yevgeny.kuznetsov@checkmarx.com>

* fix(vulnerabilities): update dockerfile and fix trivy vulnerabilities (#8076)

* update: dockerfile and fix vulnerabilities

* update: dockerfile with arguments before both FROM for universal scope

* update: vulnerable packages and dockerfile images

* ci: trigger

* fix: dockerfile deprecation notice for LegacyKeyValueFormat

---------

Signed-off-by: StepSecurity Bot <bot@stepsecurity.io>
Signed-off-by: Yevgeny Kuznetsov <yevgeny.kuznetsov@checkmarx.com>
Co-authored-by: cx-miguel-silva <100352574+cx-miguel-silva@users.noreply.github.com>
Co-authored-by: stepsecurity-app[bot] <188008098+stepsecurity-app[bot]@users.noreply.github.com>
Co-authored-by: Ohad Israeli <243351248+cx-ohad-israeli@users.noreply.github.com>
Co-authored-by: Yevgeny Kuznetsov <yevgeny.kuznetsov@checkmarx.com>
Co-authored-by: Artur Ribeiro <153724638+cx-artur-ribeiro@users.noreply.github.com>

* Requested change

* update images and pacakges for vulnerabilities

* bump compress to 1.18.7

---------

Signed-off-by: StepSecurity Bot <bot@stepsecurity.io>
Signed-off-by: Yevgeny Kuznetsov <yevgeny.kuznetsov@checkmarx.com>
Co-authored-by: Ricardo Jesus <219317970+cx-ricardo-jesus@users.noreply.github.com>
Co-authored-by: Artur Ribeiro <153724638+cx-artur-ribeiro@users.noreply.github.com>
Co-authored-by: Bruno Silva <73999905+cx-bruno-silva@users.noreply.github.com>
Co-authored-by: Rui Araújo Gomes <110477212+cx-rui-araujo@users.noreply.github.com>
Co-authored-by: João Reigota <74597872+cx-joao-reigota@users.noreply.github.com>
Co-authored-by: Rafael Carvalho <153817659+cx-rafael-carvalho@users.noreply.github.com>
Co-authored-by: stepsecurity-app[bot] <188008098+stepsecurity-app[bot]@users.noreply.github.com>
Co-authored-by: Ohad Israeli <243351248+cx-ohad-israeli@users.noreply.github.com>
Co-authored-by: Yevgeny Kuznetsov <yevgeny.kuznetsov@checkmarx.com>
Co-authored-by: Miguel da Silva <100352574+cx-miguel-dasilva@users.noreply.github.com>
Co-authored-by: cx-miguel-silva <100352574+cx-miguel-silva@users.noreply.github.com>

* updated query to support parameters (#8086)

* fix(queries): fixed FN on run/script block injection query for github/cicd (#8089)

* added coverage for github.event.comment.user.login in issue_comment event type

* added coverage for some pattern in push events in Run Block Injection query

* added coverage for some pattern in push events in Script Block Injection query

* added pattern that was only covered by the run block injection query

* fix(query): fixed FP for sql server database without auditing for arm (#8087)

* added new case on the negative tests

* updating query

---------

Co-authored-by: Alon Rosenhek <80337069+cx-alon-rosenhek@users.noreply.github.com>

* fix(query): fix FP on unpinned package version in pip install for dockerfile (#8090)

* solved specific FP for RUN commands with multiple flags with arguments

* added new test samples

* covered the scenarios where there is a RUN command with a list

* Re added changes that were undone during rebase / force push

* renamed tests and changed expected results to accomodate for PR 8099

* Fixed unppinned package version in pip install expected results

* E2E fixed, fix to query changed expected results, changed sample to start flagging again with said query, adjusted E2E naming so 106 from this PR is 108 (anotehr 106 was introduced and merged with master)

* minor E2E change for consistency

* Request documentation change + adjusted all samples to include count value 1 when there are multiple positive/negative samples which inludes all dockerfile queries now

* Fix for my newly added E2E tests (missed a .. that should have been /path) and adjusted E2E 25 that mentioned positive test that is now positive1

* Fix for second policy on run_using_sudo query + samples that actually test the CxPolicy that regressed + fix for existing issue that caused query to point to 'FROM' statement instead of target SUDO command (run_value sanitize)

* Fix expected results

---------

Signed-off-by: StepSecurity Bot <bot@stepsecurity.io>
Signed-off-by: Yevgeny Kuznetsov <yevgeny.kuznetsov@checkmarx.com>
Co-authored-by: Artur Ribeiro <153724638+cx-artur-ribeiro@users.noreply.github.com>
Co-authored-by: Miguel da Silva <100352574+cx-miguel-dasilva@users.noreply.github.com>
Co-authored-by: cx-miguel-silva <100352574+cx-miguel-silva@users.noreply.github.com>
Co-authored-by: Eli Shalnev <205644192+cx-eli-shalnev@users.noreply.github.com>
Co-authored-by: Ricardo Jesus <219317970+cx-ricardo-jesus@users.noreply.github.com>
Co-authored-by: Bruno Silva <73999905+cx-bruno-silva@users.noreply.github.com>
Co-authored-by: Rui Araújo Gomes <110477212+cx-rui-araujo@users.noreply.github.com>
Co-authored-by: João Reigota <74597872+cx-joao-reigota@users.noreply.github.com>
Co-authored-by: Rafael Carvalho <153817659+cx-rafael-carvalho@users.noreply.github.com>
Co-authored-by: stepsecurity-app[bot] <188008098+stepsecurity-app[bot]@users.noreply.github.com>
Co-authored-by: Ohad Israeli <243351248+cx-ohad-israeli@users.noreply.github.com>
Co-authored-by: Yevgeny Kuznetsov <yevgeny.kuznetsov@checkmarx.com>
Co-authored-by: Alon Rosenhek <80337069+cx-alon-rosenhek@users.noreply.github.com>
cx-andre-pereira added a commit that referenced this pull request Sep 29, 2026
…rt of dockerfile commands (#8115)

* fix(query): fix EFS Volume With Disabled Transit Encryption queries for multiple volumes cases (#7947)

* fix EFS Volume With Disabled Transit Encryption query for multiple volumes cases in tf and cf

* update: dockerfile images

* fix(analyzer): add failed utf conversions to unwanted files (#7997)

* add bad utf conversions to unwanted in analyzer

* add bad utf conversions to unwanted in analyzer

* update e2e tests and uts to cover valid ansible samples

* update base images

---------

Co-authored-by: cx-miguel-silva <100352574+cx-miguel-silva@users.noreply.github.com>

* Upgrade Trivy action to version 0.35.0

Updated Trivy action version from v0.34.2 to v0.35.0 in both scanning steps.

* fix(dockerhub): add token login to DockerHub (#8024)

* update: login to DockerHub to token

* bump: kics github action version

* feat(testing): add arm64 testing infra (#7998)

* add arm64 testing infra

* add arm64 testing infra

* bump images

* ci

* update e2e infra

* update e2e infra

* improve docker ubi 8 to support arm

* improve docker ubi 8 to support arm

* improve docker ubi 8 to support arm

* improve docker ubi 8 to support arm

* fix vulnerabilities

* fix vulnerabilities

* fix vulnerabilities

* fix vulnerabilities

* fix vulnerabilities

---------

Co-authored-by: cx-miguel-silva <100352574+cx-miguel-silva@users.noreply.github.com>
Co-authored-by: Artur Ribeiro <153724638+cx-artur-ribeiro@users.noreply.github.com>

* feat(tests): improving E2E HTML report and output on remediation tests (#7955)

* first commit

* rewrite previous changes

* causing remediation error on purpose

* some changes

* .

* .

* added remediatedFiles to error output in remediation tests

* restored directories removed by mistake

* removed files

* Delete assets/queries/terraform/aws/api_gateway_access_logging_disabled/payloads/all_payloads.json

* Delete assets/queries/terraform/aws/sns_topic_is_publicly_accessible/payloads/all_payloads.json

* Delete assets/queries/terraform/aws/sns_topic_is_publicly_accessible/payloads directory

* Delete assets/queries/terraform/aws/sns_topic_is_publicly_accessible/samples/sample.tf

* Delete assets/queries/terraform/gcp/ensure_essential_contacts_is_configured_for_organization/payloads/all_payloads.json

* Delete assets/queries/terraform/gcp/ensure_essential_contacts_is_configured_for_organization/payloads directory

* Delete assets/queries/terraform/gcp/ensure_gke_version_management_is_automated_using_release_channels/payloads/all_payloads.json

* Delete assets/queries/terraform/gcp/ensure_gke_version_management_is_automated_using_release_channels/payloads directory

* Delete assets/queries/terraform/gcp/google_kubernetes_engine_cluster_have_alpha_features_enabled/payloads/all_payloads.json

* Delete assets/queries/terraform/gcp/legacy_networks_do_not_exist_for_older_google_projects/payloads/test_payload.json

* Delete assets/queries/terraform/gcp/legacy_networks_do_not_exist_for_older_google_projects/payloads directory

* Delete assets/queries/terraform/gcp/logs_and_alerts_missing_audit_configuration_changes/payloads/all_payloads.json

* Delete assets/queries/terraform/gcp/logs_and_alerts_missing_audit_configuration_changes/payloads directory

* Delete assets/queries/terraform/gcp/logs_and_alerts_missing_custom_role_changes/test/test.tf

* Delete assets/queries/terraform/gcp/logs_and_alerts_missing_custom_role_changes/payloads directory

* Delete assets/queries/terraform/gcp/logs_and_alerts_missing_project_ownership_assignment_and_changes/payloads/positive1_payload.json

* Delete assets/queries/terraform/gcp/logs_and_alerts_missing_project_ownership_assignment_and_changes/payloads directory

* Delete assets/queries/terraform/gcp/shielded_gke_node_do_not_have_integrity_monitoring_enabled/payloads/all_payloads.json

* Delete assets/queries/terraform/gcp/shielded_gke_node_do_not_have_integrity_monitoring_enabled/payloads directory

* Delete assets/queries/terraform/gcp/sql_db_instance_external_scripts_enabled/test/negative.tf

* Delete assets/queries/terraform/gcp/sql_db_instance_external_scripts_enabled/test directory

* Delete assets/queries/terraform/gcp/sql_db_instance_external_scripts_enabled directory

* added remediation problems to the query

* fixed golint problems

* golint

* change on the query

* fixing line that surpasses the 140 characters limits by go-ci/lint

* .

* changed e2e test to see HTML results output

* .

* .

* .

* removed one query in the results

* indenting json output on E2E test HTML report

* changed fixture results

* changed comparison using listA and list B, to Expected and Actual lists

* some changes on the json output

* reverted changes on E2E results outputs

* put listA and listB side by side

* fully implemented red line for diff line

* added queryName in the output

* final improvement on HTML E2E test results output

* removed unnecessary comment

* revert changes made on E2E fixtures

* reverted changes on E2E files

* reverted changes on E2E files

* reverted changes on the wrong go template file

* fixing go lint errors

* fixing go lint error

* go lint error fixing

* go lint error fixing

* go lint error fixing

* fixing go lint errors

* fixing go lint errors

* fixing go lint errors

* fixing go lint errors

* fixing go lint errors

* fixing go lint errors

* keeping up with the codacy quality standards

* improvements on the code

* trimmed lines before direct comparisons

* adding the e2e-report file again

* changing google.golang.org/grpc version from 1.77.0 to 1.79.3

* fixed analyze command in e2e test

* covered FileStats field comparison on e2e tests

* reverting changes made on analyze.go file

* changed moby/buildkit version from 0.26.3 to 0.28.1

* revert changes

* changed moby/buildkit version from 0.26.3 to 0.28.1

* fixing unproperly formatted code

* fixed path

* fixed unproperly formatted code

* removed commented code

* fixed some E2E tests not showing the intended output format

* final fix for the tests that are currently without the proper HTML report output format

* changing code to reduce cyclomatic complexity

* fixing code to be properly formatted

* removed unnecessary printf's

* fixing the code using gofmt

* changed github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream and github.com/aws/aws-sdk-go-v2/service/s3 version in go.mod

---------

Co-authored-by: Artur Ribeiro <153724638+cx-artur-ribeiro@users.noreply.github.com>

* fix(workflows): update github actions to use SHA (#8035)

* Update github action to use SHA

* Update vulnerable dependency

* Update dockerfiles to use go 1.26.2

* Rollback go.mod to 1.25.5

* Fix vulnerabilities

* Fix vulnerabilities

* Update go version

* Suppress vulnerability

* Update dockerfile

* Update .grype.yaml

Co-authored-by: Rui Araújo Gomes <110477212+cx-rui-araujo@users.noreply.github.com>

* Small update

---------

Co-authored-by: Rui Araújo Gomes <110477212+cx-rui-araujo@users.noreply.github.com>

* feat(action): added validation for searchLine field in actions (#7994)

* changed go-ci.yml to use a script to check searchLine

* .

* fixed print to not use f when is missing placeholders

* removed unnecessary action

* fixed typo

* fixing issues from codacy

* updated go image in Dockerfile

* update go images

* changed git image

* changing positive expected results

* added requests to requirements file

* changed searchLine to get -1 value

* added debug prints

* added exception type

* fixing error in script

* removed trailing whitespace

* changed to run the other script

* debugging test directory path

* changed scripts that run on the action

* removed f-string without placeholders

* inverted changes on the query

* changed positive_expected_result

* changed filename to fileName

* added print for debugging processes

* added print to see content value

* changed script

* testing searchLine != searchLine

* removed unnecessary sorting on the results in execution context

* removed unused requirements.txt file

* reverter changes on positie_expected_results

* changes on the script and removed unnecessary go setup

* changed query to get errors on go-ci action

* parsing json data into objects

* small change to test if this is the root of the problem

* reverted changes

* fixing misspelled directory name

* fixing some errors in the script used in the validate-search-line job in go-ci action

* fixed misspelled field in validate_scan_results function

* simplifying code

* using pymarshal to use models that unmarshal json content directly

* fixing errors in results_models pymarshal import

* testing searchLine defined to '-1' hardcoded value

* convert line and searchLine to int

* adding print's for debug purposes

* adding print's for debug purposes

* fixing cases where searchLine is defined to an hardcoded value of -1

* added prints for debug purposes

* debug prints

* debug prints

* debug prints

* changes for debug purposes

* .

* changes

* trying to fix cases with -1 hardcoded on searchLine

* changes

* more changes

* trying type_assert

* trying type_assert

* trying type_assert

* trying type_assert

* trying type_assert

* testing new scenario

* testing test3 case from artur test branch

* testing test3 case from artur test branch

* back to the other scenario

* back to the other scenario again

* used unmarshal_json from pumarshal to unmarshal the json with the results

* testing hardcoded .1 again

* trying case - common_lib.build_search_line([shdfosdhfoisdhf], []),

* reverting changes on dockerfiles

* removed the usage of type_assert to be more permissive about fields not defined on the results file

* changed to see other case output in the actions

* added field queries_failed_to_execute

* changing query searchLine field to test another scenario

* changed to another scenario

* reverting changes made on the query

* changed to test scenario when "searchLine": common_lib.build_search_line(["potatos"], [])

* testing scenario where searchLine is defined to '-1'

* removed unnecessary pymarshal pip instalation

* testing another scenario

* testing searchLine defined to '-1'

* testing searchLine defined to 'potatos'

* reverting query changezs

* reverting changes on query

* reverting changes on docker files

* reverting changes on dockerfiles

* removed \n

* adding debug prints to see the output from variables produced by dorny/path

* added \n

* added echo for debug purposes

* Reverting changes on Dockerfile

* adding print on script

* testing outcome

* using Set Up python step outcome value to define if validate search line in modified queries runs or not

* changing go-jose version

* changing script code to match Codacy best practices

* changing code to comply with the Codacy quality standards

* changing go.mod

* fixing Codacy issues

* changing Go and Git images on Dockerfile

* changing go.mod

* reverting changes on go.mod

* changing go version

* fixing scripts according to Codacy issues

* fixing script to be up to the Codacy quality standards

* fixing Codacy issues

* fixing Codacy issues

* fixing Codacy issues

* fixing D212 in validate_search_line.py file

* reverting changes to fix D212

---------

Co-authored-by: Artur Ribeiro <153724638+cx-artur-ribeiro@users.noreply.github.com>

* Change to use actions role (#8040)

* Change to use actions role

* Update run-projects.yaml

* ci(secrets): use aws oidc (#8041)

* ci: fix aws secrets

* ci: fix permissions

* ci: remove audience

* ci: test gh token

* ci: use sha

* fix(query): fix FP results on "IAM policy allows for data exfiltration" CloudFormation and Terraform queries (#8030)

* Added missing check/associated tests to cloudFormation and Terraform iam_policy data exfiltration queries

---------

Co-authored-by: Artur Ribeiro <153724638+cx-artur-ribeiro@users.noreply.github.com>

* [StepSecurity] Apply security best practices (#8060)

Signed-off-by: StepSecurity Bot <bot@stepsecurity.io>
Co-authored-by: stepsecurity-app[bot] <188008098+stepsecurity-app[bot]@users.noreply.github.com>

* [StepSecurity] Apply security best practices (#8063)

Signed-off-by: StepSecurity Bot <bot@stepsecurity.io>
Co-authored-by: stepsecurity-app[bot] <188008098+stepsecurity-app[bot]@users.noreply.github.com>

* chore: remove Dependabot configuration

* Remove old SBOM (#8071)

Signed-off-by: Yevgeny Kuznetsov <yevgeny.kuznetsov@checkmarx.com>

* fix(vulnerabilities): update dockerfile and fix trivy vulnerabilities (#8076)

* update: dockerfile and fix vulnerabilities

* update: dockerfile with arguments before both FROM for universal scope

* update: vulnerable packages and dockerfile images

* ci: trigger

* fix: dockerfile deprecation notice for LegacyKeyValueFormat

* First tests

* First commit with changes to all dockerfile queries for case insesitivity support + tests

* Fixes for queries that require extra commands and some expected results fixed

* Small fix to update instruction alone query

* Test changes for payload compatibility

* Testings possible fix for parsing issue (multiple From statements)

* Removed needless check

* Fixes

* Mini fix for linting

* Added id to distinguish repeated FROM statements on the same image (lower query overhead)

* Linting fix 2

* Best of both worlds solution, fallback to the implementation that changes searchKey but now only changes if warranted, simplified distinction between identical FROM statements in the payload with a Endline-1 in brackets, SimId will vary if lines shift (exclusively on duplicate FROM statements that flag)

* slight changes to query

* SimID now depends on number of duplicate FROM statements prior to the one being evaluared, searchKey include number of duplicate and linehint (as before) in that order, latter is extracted before simID calculation

* If it is decided that altered image name can be kept queries can stay simplified since the simID will be distict already

* Revert accidental line change in positive3

* Small fix unit test

* SearchKey values in results are now sanitized of extra ^hintLine added, the value is used for search purposes and then stripped

* Moved auxiliary functions to common library and adjusted all queries to use the lineHint, added new E2E test on new multistage sample (note test is 107 because 106 should be added by another PR)

* Files that should have been in previous commit

* Fix E2E testcase

* Adjusted expected results for same alias in different forms query

* E2E fixture fix and typo fix

* Unit test to ensure line hint is being used on docker_detect

* Added unit test to docker parser to ensure duplicate FROMs are distinct commands in payload

* Added unit test to vulnerability builder to ensure line hint is removed from searchKey

* Changed identification of docker files to be case insensitive on files named 'dockerfile'

* removed legacy redundant function 'isDockerfile' from analyzer

* Improved dockerfile identification to account for relevant folder names and all files with prefix 'dockerfile.' as well as all files with the '.dockerfile' extension type in a case insensitive matter (improvement on first commit)

* Fixed 'dockerfile' keyword not being recognized as a valid file extension, added support for all ubi8/debian files in case of valid dockerfile structure, added support for lower case dockerfile commands - most queries will have issues with this but relevant text files are properly detected as a 'dockerfile' as intended

* Minor optimization

* Initial test files/cases plus minor changes to supported dockerfile formats for consistency

* Added new helper function 'isDockerfileExtension' to get_extension utility to lower cyclomatic complexity

* reverted accidental query change, fixed linting errors, fixed test errors, fixed 'gitignore' files exclusion, docker parser will handle said case like before but with explicit 'gitignore' extension rather than 'possibleDockerfile' like before

* linting fix and optimized case of file named dockerfile without extension so that it 1- gets detected regardless of syntax inside 2- gets detected withouth checking syntax inside through the code optimizing detection speed for said files

* More changes to fix go lint, d variable so 'dockerfile' is not used twice and minor simplificaton of query arguments

* Added samples for case insensitive testing on dockerfiles, added E2E test 105, improved uni tests to include new case insensitive samples

* fix for E2E

* Changed relevant functions to always treat/set the extension of valid dockerfiles as '.dockerfile'

* Removed last mention of 'dockerfile' without dot notation

* Changed 'gitignore' check for better check order in 'GetExtension' function

* Slightly more restrictive check to FROM command to ensure it has a trailing whitespace

* Updates to functions, removed unnecessary if statement on scan.go and unnecessary 'gitignore' case in analyzer's workers

* fix previous commit

* fix analyzer uni tests

* simplified new if condition

* lint fix

* fixed analyze unit tests, with names ending in 'gitignore' no longer have to be explicitly set as unwanted to allign with '.gitignore' behaviour

* Case-insensitive unit tests for dockerfile samples

* Slight changes to new test

* Slight simplification of new docker/parser unit test

* Mini fix on insensitive_sample

* Changed E2E to 106 to fix merge conflict

* fix E2E tests

* Final E2E fix

* Update to 'Docker' related documentation

* Requested change - made extDockerfile a constant

* Fixed E2E 106 fixture 'RESULT' file name

* Refactor to 'get_extension' and 'analyzer' to reduce redudancy

* Lint error fix

* Newline removed (lint)

* Renamed variable to prevent confusing shadowing

* Requested E2E change

* Removed .ubi8 and .debian extensions checks

* Fallback on debian and ubi removal from docker/parser to test E2E

* E2E test 2

* New 'python' samples to test for edge case 'from' statements on files without extension or within docker folder, adjusted readPossibleDockerfile to an improved regex based logic, adjusted file.Dockerfile to test for whitespaces before a from statement

* New samples and improved, tailored regex for dockerfile FROM statement identification - E2E test should break

* Removed duplicated sample(negative) that was in positive test fixture dockerfile folder, updated E2E results

* Final fix for E2E plus the test file removal that should have been in previous commit

* Updates E2E fixtures

* First fix attempt on validate-search-line script

* Removed need to do -1 when calling line hint function and updated documentation to reflect specific dockerfile searchKey building

* Fixed expected and actual values for using_platform_with_from query

* Fix E2E results

* Made UrlRegex a constant

* New samples, changed fockerfile syntax identification to aproach to exclusion based regex

* Linter fix

* The actual linter fix

* Fixed dokcerfile lib from statement function LineHint value so multiline FROM statements are compatible, fixed whitespace support for ARG/comments in dockerfiles and fix new E2E results

* Fix E2E 107

* First tests

* First commit with changes to all dockerfile queries for case insesitivity support + tests

* Fixes for queries that require extra commands and some expected results fixed

* Small fix to update instruction alone query

* Test changes for payload compatibility

* Testings possible fix for parsing issue (multiple From statements)

* Removed needless check

* Fixes

* Mini fix for linting

* Added id to distinguish repeated FROM statements on the same image (lower query overhead)

* Linting fix 2

* Best of both worlds solution, fallback to the implementation that changes searchKey but now only changes if warranted, simplified distinction between identical FROM statements in the payload with a Endline-1 in brackets, SimId will vary if lines shift (exclusively on duplicate FROM statements that flag)

* slight changes to query

* SimID now depends on number of duplicate FROM statements prior to the one being evaluared, searchKey include number of duplicate and linehint (as before) in that order, latter is extracted before simID calculation

* If it is decided that altered image name can be kept queries can stay simplified since the simID will be distict already

* Revert accidental line change in positive3

* Small fix unit test

* SearchKey values in results are now sanitized of extra ^hintLine added, the value is used for search purposes and then stripped

* Moved auxiliary functions to common library and adjusted all queries to use the lineHint, added new E2E test on new multistage sample (note test is 107 because 106 should be added by another PR)

* Files that should have been in previous commit

* Fix E2E testcase

* Adjusted expected results for same alias in different forms query

* E2E fixture fix and typo fix

* Unit test to ensure line hint is being used on docker_detect

* Added unit test to docker parser to ensure duplicate FROMs are distinct commands in payload

* Added unit test to vulnerability builder to ensure line hint is removed from searchKey

* Changed identification of docker files to be case insensitive on files named 'dockerfile'

* removed legacy redundant function 'isDockerfile' from analyzer

* Improved dockerfile identification to account for relevant folder names and all files with prefix 'dockerfile.' as well as all files with the '.dockerfile' extension type in a case insensitive matter (improvement on first commit)

* Fixed 'dockerfile' keyword not being recognized as a valid file extension, added support for all ubi8/debian files in case of valid dockerfile structure, added support for lower case dockerfile commands - most queries will have issues with this but relevant text files are properly detected as a 'dockerfile' as intended

* Minor optimization

* Initial test files/cases plus minor changes to supported dockerfile formats for consistency

* Added new helper function 'isDockerfileExtension' to get_extension utility to lower cyclomatic complexity

* reverted accidental query change, fixed linting errors, fixed test errors, fixed 'gitignore' files exclusion, docker parser will handle said case like before but with explicit 'gitignore' extension rather than 'possibleDockerfile' like before

* linting fix and optimized case of file named dockerfile without extension so that it 1- gets detected regardless of syntax inside 2- gets detected withouth checking syntax inside through the code optimizing detection speed for said files

* More changes to fix go lint, d variable so 'dockerfile' is not used twice and minor simplificaton of query arguments

* Added samples for case insensitive testing on dockerfiles, added E2E test 105, improved uni tests to include new case insensitive samples

* fix for E2E

* Changed relevant functions to always treat/set the extension of valid dockerfiles as '.dockerfile'

* Removed last mention of 'dockerfile' without dot notation

* Changed 'gitignore' check for better check order in 'GetExtension' function

* Slightly more restrictive check to FROM command to ensure it has a trailing whitespace

* Updates to functions, removed unnecessary if statement on scan.go and unnecessary 'gitignore' case in analyzer's workers

* fix previous commit

* fix analyzer uni tests

* simplified new if condition

* lint fix

* fixed analyze unit tests, with names ending in 'gitignore' no longer have to be explicitly set as unwanted to allign with '.gitignore' behaviour

* Case-insensitive unit tests for dockerfile samples

* Slight changes to new test

* Slight simplification of new docker/parser unit test

* Mini fix on insensitive_sample

* Changed E2E to 106 to fix merge conflict

* fix E2E tests

* Final E2E fix

* Update to 'Docker' related documentation

* Requested change - made extDockerfile a constant

* Fixed E2E 106 fixture 'RESULT' file name

* Refactor to 'get_extension' and 'analyzer' to reduce redudancy

* Lint error fix

* Newline removed (lint)

* Renamed variable to prevent confusing shadowing

* Requested E2E change

* Removed .ubi8 and .debian extensions checks

* Fallback on debian and ubi removal from docker/parser to test E2E

* E2E test 2

* Final fix E2E, the E2E itself was incorrect, payload included invalid .debian and .ubi8 files since they were still considered supported even though now .dockerfile is the only valid dockerfile extension resulting from the 'GetExtension' function

* New 'python' samples to test for edge case 'from' statements on files without extension or within docker folder, adjusted readPossibleDockerfile to an improved regex based logic, adjusted file.Dockerfile to test for whitespaces before a from statement

* New samples and improved, tailored regex for dockerfile FROM statement identification - E2E test should break

* Removed duplicated sample(negative) that was in positive test fixture dockerfile folder, updated E2E results

* Final fix for E2E plus the test file removal that should have been in previous commit

* Fix previous merge with #7995

* Updates E2E fixtures

* First fix attempt on validate-search-line script

* Removed need to do -1 when calling line hint function and updated documentation to reflect specific dockerfile searchKey building

* Fixed expected and actual values for using_platform_with_from query

* Fix E2E results

* Made UrlRegex a constant

* New samples, changed fockerfile syntax identification to aproach to exclusion based regex

* Linter fix

* The actual linter fix

* E2E fix

* Fixed dokcerfile lib from statement function LineHint value so multiline FROM statements are compatible, fixed whitespace support for ARG/comments in dockerfiles and fix new E2E results

* Fix E2E 107

* fix changed files to pre-rebase state

* Fixed value attribution that should have been comparison

* bug(security): fix security vulnerability findings (#8084)

* fix insecure temp file

* fix insecure temp file perms

* add path traversal sanitation

* add path traversal sanitization

* add path traversal sanitization tests

* add path traversal sanitization e2e tests

* add path traversal sanitization e2e tests

* fix lint issues

* fix secrets inspector possible resource exhaustion

* fix secrets line detection for end of document specific case

* bump deps and actions versions

* bump deps and actions versions

* [StepSecurity] Apply security best practices (#8060)

Signed-off-by: StepSecurity Bot <bot@stepsecurity.io>
Co-authored-by: stepsecurity-app[bot] <188008098+stepsecurity-app[bot]@users.noreply.github.com>

* [StepSecurity] Apply security best practices (#8063)

Signed-off-by: StepSecurity Bot <bot@stepsecurity.io>
Co-authored-by: stepsecurity-app[bot] <188008098+stepsecurity-app[bot]@users.noreply.github.com>

* chore: remove Dependabot configuration

* Remove old SBOM (#8071)

Signed-off-by: Yevgeny Kuznetsov <yevgeny.kuznetsov@checkmarx.com>

* fix(vulnerabilities): update dockerfile and fix trivy vulnerabilities (#8076)

* update: dockerfile and fix vulnerabilities

* update: dockerfile with arguments before both FROM for universal scope

* update: vulnerable packages and dockerfile images

* ci: trigger

* fix: dockerfile deprecation notice for LegacyKeyValueFormat

---------

Signed-off-by: StepSecurity Bot <bot@stepsecurity.io>
Signed-off-by: Yevgeny Kuznetsov <yevgeny.kuznetsov@checkmarx.com>
Co-authored-by: cx-miguel-silva <100352574+cx-miguel-silva@users.noreply.github.com>
Co-authored-by: stepsecurity-app[bot] <188008098+stepsecurity-app[bot]@users.noreply.github.com>
Co-authored-by: Ohad Israeli <243351248+cx-ohad-israeli@users.noreply.github.com>
Co-authored-by: Yevgeny Kuznetsov <yevgeny.kuznetsov@checkmarx.com>
Co-authored-by: Artur Ribeiro <153724638+cx-artur-ribeiro@users.noreply.github.com>

* fix(parser): fixed looping behavior triggered during dockerfile parsing  (#8085)

* fixs for ast 154904, loop on RUN commands and 2 unrelated queries changed

* Fixed unnecessary space affecting distance calculation/ line in vulnerability result

* Update packages again

* fix(query): updated "SQL DB Instance With SSL Disabled" Terraform query to handle 'require_ssl' field deprecation  (#8029)

* First commit: udpated query to handle deprecation of 'require_ssl' field, support for all 'ssl_mode' field values, new tests and metadata Url updated

* Small change to comments for consistency sake

* New samples and auxiliary functions to properly handle SQLSERVER databases (do not support 'TRUSTED_CLIENT_CERTIFICATE_REQUIRED' value

* Expected values and some test changes

* Fix expected results again

---------

Co-authored-by: Alon Rosenhek <80337069+cx-alon-rosenhek@users.noreply.github.com>

* fix(query): the "Image Version Using Latest" dockerfile query was not accounting for specific digest values (#8033)

* Fix check for ':latest' to ensure it is used as a sufix on the image reference (no @sha...)

* feat(tests): improving E2E HTML report and output on remediation tests (#7955)

* first commit

* rewrite previous changes

* causing remediation error on purpose

* some changes

* .

* .

* added remediatedFiles to error output in remediation tests

* restored directories removed by mistake

* removed files

* Delete assets/queries/terraform/aws/api_gateway_access_logging_disabled/payloads/all_payloads.json

* Delete assets/queries/terraform/aws/sns_topic_is_publicly_accessible/payloads/all_payloads.json

* Delete assets/queries/terraform/aws/sns_topic_is_publicly_accessible/payloads directory

* Delete assets/queries/terraform/aws/sns_topic_is_publicly_accessible/samples/sample.tf

* Delete assets/queries/terraform/gcp/ensure_essential_contacts_is_configured_for_organization/payloads/all_payloads.json

* Delete assets/queries/terraform/gcp/ensure_essential_contacts_is_configured_for_organization/payloads directory

* Delete assets/queries/terraform/gcp/ensure_gke_version_management_is_automated_using_release_channels/payloads/all_payloads.json

* Delete assets/queries/terraform/gcp/ensure_gke_version_management_is_automated_using_release_channels/payloads directory

* Delete assets/queries/terraform/gcp/google_kubernetes_engine_cluster_have_alpha_features_enabled/payloads/all_payloads.json

* Delete assets/queries/terraform/gcp/legacy_networks_do_not_exist_for_older_google_projects/payloads/test_payload.json

* Delete assets/queries/terraform/gcp/legacy_networks_do_not_exist_for_older_google_projects/payloads directory

* Delete assets/queries/terraform/gcp/logs_and_alerts_missing_audit_configuration_changes/payloads/all_payloads.json

* Delete assets/queries/terraform/gcp/logs_and_alerts_missing_audit_configuration_changes/payloads directory

* Delete assets/queries/terraform/gcp/logs_and_alerts_missing_custom_role_changes/test/test.tf

* Delete assets/queries/terraform/gcp/logs_and_alerts_missing_custom_role_changes/payloads directory

* Delete assets/queries/terraform/gcp/logs_and_alerts_missing_project_ownership_assignment_and_changes/payloads/positive1_payload.json

* Delete assets/queries/terraform/gcp/logs_and_alerts_missing_project_ownership_assignment_and_changes/payloads directory

* Delete assets/queries/terraform/gcp/shielded_gke_node_do_not_have_integrity_monitoring_enabled/payloads/all_payloads.json

* Delete assets/queries/terraform/gcp/shielded_gke_node_do_not_have_integrity_monitoring_enabled/payloads directory

* Delete assets/queries/terraform/gcp/sql_db_instance_external_scripts_enabled/test/negative.tf

* Delete assets/queries/terraform/gcp/sql_db_instance_external_scripts_enabled/test directory

* Delete assets/queries/terraform/gcp/sql_db_instance_external_scripts_enabled directory

* added remediation problems to the query

* fixed golint problems

* golint

* change on the query

* fixing line that surpasses the 140 characters limits by go-ci/lint

* .

* changed e2e test to see HTML results output

* .

* .

* .

* removed one query in the results

* indenting json output on E2E test HTML report

* changed fixture results

* changed comparison using listA and list B, to Expected and Actual lists

* some changes on the json output

* reverted changes on E2E results outputs

* put listA and listB side by side

* fully implemented red line for diff line

* added queryName in the output

* final improvement on HTML E2E test results output

* removed unnecessary comment

* revert changes made on E2E fixtures

* reverted changes on E2E files

* reverted changes on E2E files

* reverted changes on the wrong go template file

* fixing go lint errors

* fixing go lint error

* go lint error fixing

* go lint error fixing

* go lint error fixing

* fixing go lint errors

* fixing go lint errors

* fixing go lint errors

* fixing go lint errors

* fixing go lint errors

* fixing go lint errors

* keeping up with the codacy quality standards

* improvements on the code

* trimmed lines before direct comparisons

* adding the e2e-report file again

* changing google.golang.org/grpc version from 1.77.0 to 1.79.3

* fixed analyze command in e2e test

* covered FileStats field comparison on e2e tests

* reverting changes made on analyze.go file

* changed moby/buildkit version from 0.26.3 to 0.28.1

* revert changes

* changed moby/buildkit version from 0.26.3 to 0.28.1

* fixing unproperly formatted code

* fixed path

* fixed unproperly formatted code

* removed commented code

* fixed some E2E tests not showing the intended output format

* final fix for the tests that are currently without the proper HTML report output format

* changing code to reduce cyclomatic complexity

* fixing code to be properly formatted

* removed unnecessary printf's

* fixing the code using gofmt

* changed github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream and github.com/aws/aws-sdk-go-v2/service/s3 version in go.mod

---------

Co-authored-by: Artur Ribeiro <153724638+cx-artur-ribeiro@users.noreply.github.com>

* fix(workflows): update github actions to use SHA (#8035)

* Update github action to use SHA

* Update vulnerable dependency

* Update dockerfiles to use go 1.26.2

* Rollback go.mod to 1.25.5

* Fix vulnerabilities

* Fix vulnerabilities

* Update go version

* Suppress vulnerability

* Update dockerfile

* Update .grype.yaml

Co-authored-by: Rui Araújo Gomes <110477212+cx-rui-araujo@users.noreply.github.com>

* Small update

---------

Co-authored-by: Rui Araújo Gomes <110477212+cx-rui-araujo@users.noreply.github.com>

* feat(action): added validation for searchLine field in actions (#7994)

* changed go-ci.yml to use a script to check searchLine

* .

* fixed print to not use f when is missing placeholders

* removed unnecessary action

* fixed typo

* fixing issues from codacy

* updated go image in Dockerfile

* update go images

* changed git image

* changing positive expected results

* added requests to requirements file

* changed searchLine to get -1 value

* added debug prints

* added exception type

* fixing error in script

* removed trailing whitespace

* changed to run the other script

* debugging test directory path

* changed scripts that run on the action

* removed f-string without placeholders

* inverted changes on the query

* changed positive_expected_result

* changed filename to fileName

* added print for debugging processes

* added print to see content value

* changed script

* testing searchLine != searchLine

* removed unnecessary sorting on the results in execution context

* removed unused requirements.txt file

* reverter changes on positie_expected_results

* changes on the script and removed unnecessary go setup

* changed query to get errors on go-ci action

* parsing json data into objects

* small change to test if this is the root of the problem

* reverted changes

* fixing misspelled directory name

* fixing some errors in the script used in the validate-search-line job in go-ci action

* fixed misspelled field in validate_scan_results function

* simplifying code

* using pymarshal to use models that unmarshal json content directly

* fixing errors in results_models pymarshal import

* testing searchLine defined to '-1' hardcoded value

* convert line and searchLine to int

* adding print's for debug purposes

* adding print's for debug purposes

* fixing cases where searchLine is defined to an hardcoded value of -1

* added prints for debug purposes

* debug prints

* debug prints

* debug prints

* changes for debug purposes

* .

* changes

* trying to fix cases with -1 hardcoded on searchLine

* changes

* more changes

* trying type_assert

* trying type_assert

* trying type_assert

* trying type_assert

* trying type_assert

* testing new scenario

* testing test3 case from artur test branch

* testing test3 case from artur test branch

* back to the other scenario

* back to the other scenario again

* used unmarshal_json from pumarshal to unmarshal the json with the results

* testing hardcoded .1 again

* trying case - common_lib.build_search_line([shdfosdhfoisdhf], []),

* reverting changes on dockerfiles

* removed the usage of type_assert to be more permissive about fields not defined on the results file

* changed to see other case output in the actions

* added field queries_failed_to_execute

* changing query searchLine field to test another scenario

* changed to another scenario

* reverting changes made on the query

* changed to test scenario when "searchLine": common_lib.build_search_line(["potatos"], [])

* testing scenario where searchLine is defined to '-1'

* removed unnecessary pymarshal pip instalation

* testing another scenario

* testing searchLine defined to '-1'

* testing searchLine defined to 'potatos'

* reverting query changezs

* reverting changes on query

* reverting changes on docker files

* reverting changes on dockerfiles

* removed \n

* adding debug prints to see the output from variables produced by dorny/path

* added \n

* added echo for debug purposes

* Reverting changes on Dockerfile

* adding print on script

* testing outcome

* using Set Up python step outcome value to define if validate search line in modified queries runs or not

* changing go-jose version

* changing script code to match Codacy best practices

* changing code to comply with the Codacy quality standards

* changing go.mod

* fixing Codacy issues

* changing Go and Git images on Dockerfile

* changing go.mod

* reverting changes on go.mod

* changing go version

* fixing scripts according to Codacy issues

* fixing script to be up to the Codacy quality standards

* fixing Codacy issues

* fixing Codacy issues

* fixing Codacy issues

* fixing D212 in validate_search_line.py file

* reverting changes to fix D212

---------

Co-authored-by: Artur Ribeiro <153724638+cx-artur-ribeiro@users.noreply.github.com>

* Change to use actions role (#8040)

* Change to use actions role

* Update run-projects.yaml

* ci(secrets): use aws oidc (#8041)

* ci: fix aws secrets

* ci: fix permissions

* ci: remove audience

* ci: test gh token

* ci: use sha

* fix(query): fix FP results on "IAM policy allows for data exfiltration" CloudFormation and Terraform queries (#8030)

* Added missing check/associated tests to cloudFormation and Terraform iam_policy data exfiltration queries

---------

Co-authored-by: Artur Ribeiro <153724638+cx-artur-ribeiro@users.noreply.github.com>

* [StepSecurity] Apply security best practices (#8060)

Signed-off-by: StepSecurity Bot <bot@stepsecurity.io>
Co-authored-by: stepsecurity-app[bot] <188008098+stepsecurity-app[bot]@users.noreply.github.com>

* [StepSecurity] Apply security best practices (#8063)

Signed-off-by: StepSecurity Bot <bot@stepsecurity.io>
Co-authored-by: stepsecurity-app[bot] <188008098+stepsecurity-app[bot]@users.noreply.github.com>

* chore: remove Dependabot configuration

* Remove old SBOM (#8071)

Signed-off-by: Yevgeny Kuznetsov <yevgeny.kuznetsov@checkmarx.com>

* fix(vulnerabilities): update dockerfile and fix trivy vulnerabilities (#8076)

* update: dockerfile and fix vulnerabilities

* update: dockerfile with arguments before both FROM for universal scope

* update: vulnerable packages and dockerfile images

* ci: trigger

* fix: dockerfile deprecation notice for LegacyKeyValueFormat

* bug(security): fix security vulnerability findings (#8084)

* fix insecure temp file

* fix insecure temp file perms

* add path traversal sanitation

* add path traversal sanitization

* add path traversal sanitization tests

* add path traversal sanitization e2e tests

* add path traversal sanitization e2e tests

* fix lint issues

* fix secrets inspector possible resource exhaustion

* fix secrets line detection for end of document specific case

* bump deps and actions versions

* bump deps and actions versions

* [StepSecurity] Apply security best practices (#8060)

Signed-off-by: StepSecurity Bot <bot@stepsecurity.io>
Co-authored-by: stepsecurity-app[bot] <188008098+stepsecurity-app[bot]@users.noreply.github.com>

* [StepSecurity] Apply security best practices (#8063)

Signed-off-by: StepSecurity Bot <bot@stepsecurity.io>
Co-authored-by: stepsecurity-app[bot] <188008098+stepsecurity-app[bot]@users.noreply.github.com>

* chore: remove Dependabot configuration

* Remove old SBOM (#8071)

Signed-off-by: Yevgeny Kuznetsov <yevgeny.kuznetsov@checkmarx.com>

* fix(vulnerabilities): update dockerfile and fix trivy vulnerabilities (#8076)

* update: dockerfile and fix vulnerabilities

* update: dockerfile with arguments before both FROM for universal scope

* update: vulnerable packages and dockerfile images

* ci: trigger

* fix: dockerfile deprecation notice for LegacyKeyValueFormat

---------

Signed-off-by: StepSecurity Bot <bot@stepsecurity.io>
Signed-off-by: Yevgeny Kuznetsov <yevgeny.kuznetsov@checkmarx.com>
Co-authored-by: cx-miguel-silva <100352574+cx-miguel-silva@users.noreply.github.com>
Co-authored-by: stepsecurity-app[bot] <188008098+stepsecurity-app[bot]@users.noreply.github.com>
Co-authored-by: Ohad Israeli <243351248+cx-ohad-israeli@users.noreply.github.com>
Co-authored-by: Yevgeny Kuznetsov <yevgeny.kuznetsov@checkmarx.com>
Co-authored-by: Artur Ribeiro <153724638+cx-artur-ribeiro@users.noreply.github.com>

* Requested change

* update images and pacakges for vulnerabilities

* bump compress to 1.18.7

---------

Signed-off-by: StepSecurity Bot <bot@stepsecurity.io>
Signed-off-by: Yevgeny Kuznetsov <yevgeny.kuznetsov@checkmarx.com>
Co-authored-by: Ricardo Jesus <219317970+cx-ricardo-jesus@users.noreply.github.com>
Co-authored-by: Artur Ribeiro <153724638+cx-artur-ribeiro@users.noreply.github.com>
Co-authored-by: Bruno Silva <73999905+cx-bruno-silva@users.noreply.github.com>
Co-authored-by: Rui Araújo Gomes <110477212+cx-rui-araujo@users.noreply.github.com>
Co-authored-by: João Reigota <74597872+cx-joao-reigota@users.noreply.github.com>
Co-authored-by: Rafael Carvalho <153817659+cx-rafael-carvalho@users.noreply.github.com>
Co-authored-by: stepsecurity-app[bot] <188008098+stepsecurity-app[bot]@users.noreply.github.com>
Co-authored-by: Ohad Israeli <243351248+cx-ohad-israeli@users.noreply.github.com>
Co-authored-by: Yevgeny Kuznetsov <yevgeny.kuznetsov@checkmarx.com>
Co-authored-by: Miguel da Silva <100352574+cx-miguel-dasilva@users.noreply.github.com>
Co-authored-by: cx-miguel-silva <100352574+cx-miguel-silva@users.noreply.github.com>

* updated query to support parameters (#8086)

* fix(queries): fixed FN on run/script block injection query for github/cicd (#8089)

* added coverage for github.event.comment.user.login in issue_comment event type

* added coverage for some pattern in push events in Run Block Injection query

* added coverage for some pattern in push events in Script Block Injection query

* added pattern that was only covered by the run block injection query

* fix(query): fixed FP for sql server database without auditing for arm (#8087)

* added new case on the negative tests

* updating query

---------

Co-authored-by: Alon Rosenhek <80337069+cx-alon-rosenhek@users.noreply.github.com>

* fix(query): fix FP on unpinned package version in pip install for dockerfile (#8090)

* solved specific FP for RUN commands with multiple flags with arguments

* added new test samples

* covered the scenarios where there is a RUN command with a list

* Re added changes that were undone during rebase / force push

* renamed tests and changed expected results to accomodate for PR 8099

* Fixed unppinned package version in pip install expected results

* E2E fixed, fix to query changed expected results, changed sample to start flagging again with said query, adjusted E2E naming so 106 from this PR is 108 (anotehr 106 was introduced and merged with master)

* minor E2E change for consistency

* Request documentation change + adjusted all samples to include count value 1 when there are multiple positive/negative samples which inludes all dockerfile queries now

* Fix for my newly added E2E tests (missed a .. that should have been /path) and adjusted E2E 25 that mentioned positive test that is now positive1

* Fix for second policy on run_using_sudo query + samples that actually test the CxPolicy that regressed + fix for existing issue that caused query to point to 'FROM' statement instead of target SUDO command (run_value sanitize)

* Fix expected results

---------

Signed-off-by: StepSecurity Bot <bot@stepsecurity.io>
Signed-off-by: Yevgeny Kuznetsov <yevgeny.kuznetsov@checkmarx.com>
Co-authored-by: Artur Ribeiro <153724638+cx-artur-ribeiro@users.noreply.github.com>
Co-authored-by: Miguel da Silva <100352574+cx-miguel-dasilva@users.noreply.github.com>
Co-authored-by: cx-miguel-silva <100352574+cx-miguel-silva@users.noreply.github.com>
Co-authored-by: Eli Shalnev <205644192+cx-eli-shalnev@users.noreply.github.com>
Co-authored-by: Ricardo Jesus <219317970+cx-ricardo-jesus@users.noreply.github.com>
Co-authored-by: Bruno Silva <73999905+cx-bruno-silva@users.noreply.github.com>
Co-authored-by: Rui Araújo Gomes <110477212+cx-rui-araujo@users.noreply.github.com>
Co-authored-by: João Reigota <74597872+cx-joao-reigota@users.noreply.github.com>
Co-authored-by: Rafael Carvalho <153817659+cx-rafael-carvalho@users.noreply.github.com>
Co-authored-by: stepsecurity-app[bot] <188008098+stepsecurity-app[bot]@users.noreply.github.com>
Co-authored-by: Ohad Israeli <243351248+cx-ohad-israeli@users.noreply.github.com>
Co-authored-by: Yevgeny Kuznetsov <yevgeny.kuznetsov@checkmarx.com>
Co-authored-by: Alon Rosenhek <80337069+cx-alon-rosenhek@users.noreply.github.com>
cx-andre-pereira added a commit that referenced this pull request Sep 29, 2026
…rt of dockerfile commands (#8115)

* fix(query): fix EFS Volume With Disabled Transit Encryption queries for multiple volumes cases (#7947)

* fix EFS Volume With Disabled Transit Encryption query for multiple volumes cases in tf and cf

* update: dockerfile images

* fix(analyzer): add failed utf conversions to unwanted files (#7997)

* add bad utf conversions to unwanted in analyzer

* add bad utf conversions to unwanted in analyzer

* update e2e tests and uts to cover valid ansible samples

* update base images

---------

Co-authored-by: cx-miguel-silva <100352574+cx-miguel-silva@users.noreply.github.com>

* Upgrade Trivy action to version 0.35.0

Updated Trivy action version from v0.34.2 to v0.35.0 in both scanning steps.

* fix(dockerhub): add token login to DockerHub (#8024)

* update: login to DockerHub to token

* bump: kics github action version

* feat(testing): add arm64 testing infra (#7998)

* add arm64 testing infra

* add arm64 testing infra

* bump images

* ci

* update e2e infra

* update e2e infra

* improve docker ubi 8 to support arm

* improve docker ubi 8 to support arm

* improve docker ubi 8 to support arm

* improve docker ubi 8 to support arm

* fix vulnerabilities

* fix vulnerabilities

* fix vulnerabilities

* fix vulnerabilities

* fix vulnerabilities

---------

Co-authored-by: cx-miguel-silva <100352574+cx-miguel-silva@users.noreply.github.com>
Co-authored-by: Artur Ribeiro <153724638+cx-artur-ribeiro@users.noreply.github.com>

* feat(tests): improving E2E HTML report and output on remediation tests (#7955)

* first commit

* rewrite previous changes

* causing remediation error on purpose

* some changes

* .

* .

* added remediatedFiles to error output in remediation tests

* restored directories removed by mistake

* removed files

* Delete assets/queries/terraform/aws/api_gateway_access_logging_disabled/payloads/all_payloads.json

* Delete assets/queries/terraform/aws/sns_topic_is_publicly_accessible/payloads/all_payloads.json

* Delete assets/queries/terraform/aws/sns_topic_is_publicly_accessible/payloads directory

* Delete assets/queries/terraform/aws/sns_topic_is_publicly_accessible/samples/sample.tf

* Delete assets/queries/terraform/gcp/ensure_essential_contacts_is_configured_for_organization/payloads/all_payloads.json

* Delete assets/queries/terraform/gcp/ensure_essential_contacts_is_configured_for_organization/payloads directory

* Delete assets/queries/terraform/gcp/ensure_gke_version_management_is_automated_using_release_channels/payloads/all_payloads.json

* Delete assets/queries/terraform/gcp/ensure_gke_version_management_is_automated_using_release_channels/payloads directory

* Delete assets/queries/terraform/gcp/google_kubernetes_engine_cluster_have_alpha_features_enabled/payloads/all_payloads.json

* Delete assets/queries/terraform/gcp/legacy_networks_do_not_exist_for_older_google_projects/payloads/test_payload.json

* Delete assets/queries/terraform/gcp/legacy_networks_do_not_exist_for_older_google_projects/payloads directory

* Delete assets/queries/terraform/gcp/logs_and_alerts_missing_audit_configuration_changes/payloads/all_payloads.json

* Delete assets/queries/terraform/gcp/logs_and_alerts_missing_audit_configuration_changes/payloads directory

* Delete assets/queries/terraform/gcp/logs_and_alerts_missing_custom_role_changes/test/test.tf

* Delete assets/queries/terraform/gcp/logs_and_alerts_missing_custom_role_changes/payloads directory

* Delete assets/queries/terraform/gcp/logs_and_alerts_missing_project_ownership_assignment_and_changes/payloads/positive1_payload.json

* Delete assets/queries/terraform/gcp/logs_and_alerts_missing_project_ownership_assignment_and_changes/payloads directory

* Delete assets/queries/terraform/gcp/shielded_gke_node_do_not_have_integrity_monitoring_enabled/payloads/all_payloads.json

* Delete assets/queries/terraform/gcp/shielded_gke_node_do_not_have_integrity_monitoring_enabled/payloads directory

* Delete assets/queries/terraform/gcp/sql_db_instance_external_scripts_enabled/test/negative.tf

* Delete assets/queries/terraform/gcp/sql_db_instance_external_scripts_enabled/test directory

* Delete assets/queries/terraform/gcp/sql_db_instance_external_scripts_enabled directory

* added remediation problems to the query

* fixed golint problems

* golint

* change on the query

* fixing line that surpasses the 140 characters limits by go-ci/lint

* .

* changed e2e test to see HTML results output

* .

* .

* .

* removed one query in the results

* indenting json output on E2E test HTML report

* changed fixture results

* changed comparison using listA and list B, to Expected and Actual lists

* some changes on the json output

* reverted changes on E2E results outputs

* put listA and listB side by side

* fully implemented red line for diff line

* added queryName in the output

* final improvement on HTML E2E test results output

* removed unnecessary comment

* revert changes made on E2E fixtures

* reverted changes on E2E files

* reverted changes on E2E files

* reverted changes on the wrong go template file

* fixing go lint errors

* fixing go lint error

* go lint error fixing

* go lint error fixing

* go lint error fixing

* fixing go lint errors

* fixing go lint errors

* fixing go lint errors

* fixing go lint errors

* fixing go lint errors

* fixing go lint errors

* keeping up with the codacy quality standards

* improvements on the code

* trimmed lines before direct comparisons

* adding the e2e-report file again

* changing google.golang.org/grpc version from 1.77.0 to 1.79.3

* fixed analyze command in e2e test

* covered FileStats field comparison on e2e tests

* reverting changes made on analyze.go file

* changed moby/buildkit version from 0.26.3 to 0.28.1

* revert changes

* changed moby/buildkit version from 0.26.3 to 0.28.1

* fixing unproperly formatted code

* fixed path

* fixed unproperly formatted code

* removed commented code

* fixed some E2E tests not showing the intended output format

* final fix for the tests that are currently without the proper HTML report output format

* changing code to reduce cyclomatic complexity

* fixing code to be properly formatted

* removed unnecessary printf's

* fixing the code using gofmt

* changed github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream and github.com/aws/aws-sdk-go-v2/service/s3 version in go.mod

---------

Co-authored-by: Artur Ribeiro <153724638+cx-artur-ribeiro@users.noreply.github.com>

* fix(workflows): update github actions to use SHA (#8035)

* Update github action to use SHA

* Update vulnerable dependency

* Update dockerfiles to use go 1.26.2

* Rollback go.mod to 1.25.5

* Fix vulnerabilities

* Fix vulnerabilities

* Update go version

* Suppress vulnerability

* Update dockerfile

* Update .grype.yaml

Co-authored-by: Rui Araújo Gomes <110477212+cx-rui-araujo@users.noreply.github.com>

* Small update

---------

Co-authored-by: Rui Araújo Gomes <110477212+cx-rui-araujo@users.noreply.github.com>

* feat(action): added validation for searchLine field in actions (#7994)

* changed go-ci.yml to use a script to check searchLine

* .

* fixed print to not use f when is missing placeholders

* removed unnecessary action

* fixed typo

* fixing issues from codacy

* updated go image in Dockerfile

* update go images

* changed git image

* changing positive expected results

* added requests to requirements file

* changed searchLine to get -1 value

* added debug prints

* added exception type

* fixing error in script

* removed trailing whitespace

* changed to run the other script

* debugging test directory path

* changed scripts that run on the action

* removed f-string without placeholders

* inverted changes on the query

* changed positive_expected_result

* changed filename to fileName

* added print for debugging processes

* added print to see content value

* changed script

* testing searchLine != searchLine

* removed unnecessary sorting on the results in execution context

* removed unused requirements.txt file

* reverter changes on positie_expected_results

* changes on the script and removed unnecessary go setup

* changed query to get errors on go-ci action

* parsing json data into objects

* small change to test if this is the root of the problem

* reverted changes

* fixing misspelled directory name

* fixing some errors in the script used in the validate-search-line job in go-ci action

* fixed misspelled field in validate_scan_results function

* simplifying code

* using pymarshal to use models that unmarshal json content directly

* fixing errors in results_models pymarshal import

* testing searchLine defined to '-1' hardcoded value

* convert line and searchLine to int

* adding print's for debug purposes

* adding print's for debug purposes

* fixing cases where searchLine is defined to an hardcoded value of -1

* added prints for debug purposes

* debug prints

* debug prints

* debug prints

* changes for debug purposes

* .

* changes

* trying to fix cases with -1 hardcoded on searchLine

* changes

* more changes

* trying type_assert

* trying type_assert

* trying type_assert

* trying type_assert

* trying type_assert

* testing new scenario

* testing test3 case from artur test branch

* testing test3 case from artur test branch

* back to the other scenario

* back to the other scenario again

* used unmarshal_json from pumarshal to unmarshal the json with the results

* testing hardcoded .1 again

* trying case - common_lib.build_search_line([shdfosdhfoisdhf], []),

* reverting changes on dockerfiles

* removed the usage of type_assert to be more permissive about fields not defined on the results file

* changed to see other case output in the actions

* added field queries_failed_to_execute

* changing query searchLine field to test another scenario

* changed to another scenario

* reverting changes made on the query

* changed to test scenario when "searchLine": common_lib.build_search_line(["potatos"], [])

* testing scenario where searchLine is defined to '-1'

* removed unnecessary pymarshal pip instalation

* testing another scenario

* testing searchLine defined to '-1'

* testing searchLine defined to 'potatos'

* reverting query changezs

* reverting changes on query

* reverting changes on docker files

* reverting changes on dockerfiles

* removed \n

* adding debug prints to see the output from variables produced by dorny/path

* added \n

* added echo for debug purposes

* Reverting changes on Dockerfile

* adding print on script

* testing outcome

* using Set Up python step outcome value to define if validate search line in modified queries runs or not

* changing go-jose version

* changing script code to match Codacy best practices

* changing code to comply with the Codacy quality standards

* changing go.mod

* fixing Codacy issues

* changing Go and Git images on Dockerfile

* changing go.mod

* reverting changes on go.mod

* changing go version

* fixing scripts according to Codacy issues

* fixing script to be up to the Codacy quality standards

* fixing Codacy issues

* fixing Codacy issues

* fixing Codacy issues

* fixing D212 in validate_search_line.py file

* reverting changes to fix D212

---------

Co-authored-by: Artur Ribeiro <153724638+cx-artur-ribeiro@users.noreply.github.com>

* Change to use actions role (#8040)

* Change to use actions role

* Update run-projects.yaml

* ci(secrets): use aws oidc (#8041)

* ci: fix aws secrets

* ci: fix permissions

* ci: remove audience

* ci: test gh token

* ci: use sha

* fix(query): fix FP results on "IAM policy allows for data exfiltration" CloudFormation and Terraform queries (#8030)

* Added missing check/associated tests to cloudFormation and Terraform iam_policy data exfiltration queries

---------

Co-authored-by: Artur Ribeiro <153724638+cx-artur-ribeiro@users.noreply.github.com>

* [StepSecurity] Apply security best practices (#8060)

Signed-off-by: StepSecurity Bot <bot@stepsecurity.io>
Co-authored-by: stepsecurity-app[bot] <188008098+stepsecurity-app[bot]@users.noreply.github.com>

* [StepSecurity] Apply security best practices (#8063)

Signed-off-by: StepSecurity Bot <bot@stepsecurity.io>
Co-authored-by: stepsecurity-app[bot] <188008098+stepsecurity-app[bot]@users.noreply.github.com>

* chore: remove Dependabot configuration

* Remove old SBOM (#8071)

Signed-off-by: Yevgeny Kuznetsov <yevgeny.kuznetsov@checkmarx.com>

* fix(vulnerabilities): update dockerfile and fix trivy vulnerabilities (#8076)

* update: dockerfile and fix vulnerabilities

* update: dockerfile with arguments before both FROM for universal scope

* update: vulnerable packages and dockerfile images

* ci: trigger

* fix: dockerfile deprecation notice for LegacyKeyValueFormat

* First tests

* First commit with changes to all dockerfile queries for case insesitivity support + tests

* Fixes for queries that require extra commands and some expected results fixed

* Small fix to update instruction alone query

* Test changes for payload compatibility

* Testings possible fix for parsing issue (multiple From statements)

* Removed needless check

* Fixes

* Mini fix for linting

* Added id to distinguish repeated FROM statements on the same image (lower query overhead)

* Linting fix 2

* Best of both worlds solution, fallback to the implementation that changes searchKey but now only changes if warranted, simplified distinction between identical FROM statements in the payload with a Endline-1 in brackets, SimId will vary if lines shift (exclusively on duplicate FROM statements that flag)

* slight changes to query

* SimID now depends on number of duplicate FROM statements prior to the one being evaluared, searchKey include number of duplicate and linehint (as before) in that order, latter is extracted before simID calculation

* If it is decided that altered image name can be kept queries can stay simplified since the simID will be distict already

* Revert accidental line change in positive3

* Small fix unit test

* SearchKey values in results are now sanitized of extra ^hintLine added, the value is used for search purposes and then stripped

* Moved auxiliary functions to common library and adjusted all queries to use the lineHint, added new E2E test on new multistage sample (note test is 107 because 106 should be added by another PR)

* Files that should have been in previous commit

* Fix E2E testcase

* Adjusted expected results for same alias in different forms query

* E2E fixture fix and typo fix

* Unit test to ensure line hint is being used on docker_detect

* Added unit test to docker parser to ensure duplicate FROMs are distinct commands in payload

* Added unit test to vulnerability builder to ensure line hint is removed from searchKey

* Changed identification of docker files to be case insensitive on files named 'dockerfile'

* removed legacy redundant function 'isDockerfile' from analyzer

* Improved dockerfile identification to account for relevant folder names and all files with prefix 'dockerfile.' as well as all files with the '.dockerfile' extension type in a case insensitive matter (improvement on first commit)

* Fixed 'dockerfile' keyword not being recognized as a valid file extension, added support for all ubi8/debian files in case of valid dockerfile structure, added support for lower case dockerfile commands - most queries will have issues with this but relevant text files are properly detected as a 'dockerfile' as intended

* Minor optimization

* Initial test files/cases plus minor changes to supported dockerfile formats for consistency

* Added new helper function 'isDockerfileExtension' to get_extension utility to lower cyclomatic complexity

* reverted accidental query change, fixed linting errors, fixed test errors, fixed 'gitignore' files exclusion, docker parser will handle said case like before but with explicit 'gitignore' extension rather than 'possibleDockerfile' like before

* linting fix and optimized case of file named dockerfile without extension so that it 1- gets detected regardless of syntax inside 2- gets detected withouth checking syntax inside through the code optimizing detection speed for said files

* More changes to fix go lint, d variable so 'dockerfile' is not used twice and minor simplificaton of query arguments

* Added samples for case insensitive testing on dockerfiles, added E2E test 105, improved uni tests to include new case insensitive samples

* fix for E2E

* Changed relevant functions to always treat/set the extension of valid dockerfiles as '.dockerfile'

* Removed last mention of 'dockerfile' without dot notation

* Changed 'gitignore' check for better check order in 'GetExtension' function

* Slightly more restrictive check to FROM command to ensure it has a trailing whitespace

* Updates to functions, removed unnecessary if statement on scan.go and unnecessary 'gitignore' case in analyzer's workers

* fix previous commit

* fix analyzer uni tests

* simplified new if condition

* lint fix

* fixed analyze unit tests, with names ending in 'gitignore' no longer have to be explicitly set as unwanted to allign with '.gitignore' behaviour

* Case-insensitive unit tests for dockerfile samples

* Slight changes to new test

* Slight simplification of new docker/parser unit test

* Mini fix on insensitive_sample

* Changed E2E to 106 to fix merge conflict

* fix E2E tests

* Final E2E fix

* Update to 'Docker' related documentation

* Requested change - made extDockerfile a constant

* Fixed E2E 106 fixture 'RESULT' file name

* Refactor to 'get_extension' and 'analyzer' to reduce redudancy

* Lint error fix

* Newline removed (lint)

* Renamed variable to prevent confusing shadowing

* Requested E2E change

* Removed .ubi8 and .debian extensions checks

* Fallback on debian and ubi removal from docker/parser to test E2E

* E2E test 2

* New 'python' samples to test for edge case 'from' statements on files without extension or within docker folder, adjusted readPossibleDockerfile to an improved regex based logic, adjusted file.Dockerfile to test for whitespaces before a from statement

* New samples and improved, tailored regex for dockerfile FROM statement identification - E2E test should break

* Removed duplicated sample(negative) that was in positive test fixture dockerfile folder, updated E2E results

* Final fix for E2E plus the test file removal that should have been in previous commit

* Updates E2E fixtures

* First fix attempt on validate-search-line script

* Removed need to do -1 when calling line hint function and updated documentation to reflect specific dockerfile searchKey building

* Fixed expected and actual values for using_platform_with_from query

* Fix E2E results

* Made UrlRegex a constant

* New samples, changed fockerfile syntax identification to aproach to exclusion based regex

* Linter fix

* The actual linter fix

* Fixed dokcerfile lib from statement function LineHint value so multiline FROM statements are compatible, fixed whitespace support for ARG/comments in dockerfiles and fix new E2E results

* Fix E2E 107

* First tests

* First commit with changes to all dockerfile queries for case insesitivity support + tests

* Fixes for queries that require extra commands and some expected results fixed

* Small fix to update instruction alone query

* Test changes for payload compatibility

* Testings possible fix for parsing issue (multiple From statements)

* Removed needless check

* Fixes

* Mini fix for linting

* Added id to distinguish repeated FROM statements on the same image (lower query overhead)

* Linting fix 2

* Best of both worlds solution, fallback to the implementation that changes searchKey but now only changes if warranted, simplified distinction between identical FROM statements in the payload with a Endline-1 in brackets, SimId will vary if lines shift (exclusively on duplicate FROM statements that flag)

* slight changes to query

* SimID now depends on number of duplicate FROM statements prior to the one being evaluared, searchKey include number of duplicate and linehint (as before) in that order, latter is extracted before simID calculation

* If it is decided that altered image name can be kept queries can stay simplified since the simID will be distict already

* Revert accidental line change in positive3

* Small fix unit test

* SearchKey values in results are now sanitized of extra ^hintLine added, the value is used for search purposes and then stripped

* Moved auxiliary functions to common library and adjusted all queries to use the lineHint, added new E2E test on new multistage sample (note test is 107 because 106 should be added by another PR)

* Files that should have been in previous commit

* Fix E2E testcase

* Adjusted expected results for same alias in different forms query

* E2E fixture fix and typo fix

* Unit test to ensure line hint is being used on docker_detect

* Added unit test to docker parser to ensure duplicate FROMs are distinct commands in payload

* Added unit test to vulnerability builder to ensure line hint is removed from searchKey

* Changed identification of docker files to be case insensitive on files named 'dockerfile'

* removed legacy redundant function 'isDockerfile' from analyzer

* Improved dockerfile identification to account for relevant folder names and all files with prefix 'dockerfile.' as well as all files with the '.dockerfile' extension type in a case insensitive matter (improvement on first commit)

* Fixed 'dockerfile' keyword not being recognized as a valid file extension, added support for all ubi8/debian files in case of valid dockerfile structure, added support for lower case dockerfile commands - most queries will have issues with this but relevant text files are properly detected as a 'dockerfile' as intended

* Minor optimization

* Initial test files/cases plus minor changes to supported dockerfile formats for consistency

* Added new helper function 'isDockerfileExtension' to get_extension utility to lower cyclomatic complexity

* reverted accidental query change, fixed linting errors, fixed test errors, fixed 'gitignore' files exclusion, docker parser will handle said case like before but with explicit 'gitignore' extension rather than 'possibleDockerfile' like before

* linting fix and optimized case of file named dockerfile without extension so that it 1- gets detected regardless of syntax inside 2- gets detected withouth checking syntax inside through the code optimizing detection speed for said files

* More changes to fix go lint, d variable so 'dockerfile' is not used twice and minor simplificaton of query arguments

* Added samples for case insensitive testing on dockerfiles, added E2E test 105, improved uni tests to include new case insensitive samples

* fix for E2E

* Changed relevant functions to always treat/set the extension of valid dockerfiles as '.dockerfile'

* Removed last mention of 'dockerfile' without dot notation

* Changed 'gitignore' check for better check order in 'GetExtension' function

* Slightly more restrictive check to FROM command to ensure it has a trailing whitespace

* Updates to functions, removed unnecessary if statement on scan.go and unnecessary 'gitignore' case in analyzer's workers

* fix previous commit

* fix analyzer uni tests

* simplified new if condition

* lint fix

* fixed analyze unit tests, with names ending in 'gitignore' no longer have to be explicitly set as unwanted to allign with '.gitignore' behaviour

* Case-insensitive unit tests for dockerfile samples

* Slight changes to new test

* Slight simplification of new docker/parser unit test

* Mini fix on insensitive_sample

* Changed E2E to 106 to fix merge conflict

* fix E2E tests

* Final E2E fix

* Update to 'Docker' related documentation

* Requested change - made extDockerfile a constant

* Fixed E2E 106 fixture 'RESULT' file name

* Refactor to 'get_extension' and 'analyzer' to reduce redudancy

* Lint error fix

* Newline removed (lint)

* Renamed variable to prevent confusing shadowing

* Requested E2E change

* Removed .ubi8 and .debian extensions checks

* Fallback on debian and ubi removal from docker/parser to test E2E

* E2E test 2

* Final fix E2E, the E2E itself was incorrect, payload included invalid .debian and .ubi8 files since they were still considered supported even though now .dockerfile is the only valid dockerfile extension resulting from the 'GetExtension' function

* New 'python' samples to test for edge case 'from' statements on files without extension or within docker folder, adjusted readPossibleDockerfile to an improved regex based logic, adjusted file.Dockerfile to test for whitespaces before a from statement

* New samples and improved, tailored regex for dockerfile FROM statement identification - E2E test should break

* Removed duplicated sample(negative) that was in positive test fixture dockerfile folder, updated E2E results

* Final fix for E2E plus the test file removal that should have been in previous commit

* Fix previous merge with #7995

* Updates E2E fixtures

* First fix attempt on validate-search-line script

* Removed need to do -1 when calling line hint function and updated documentation to reflect specific dockerfile searchKey building

* Fixed expected and actual values for using_platform_with_from query

* Fix E2E results

* Made UrlRegex a constant

* New samples, changed fockerfile syntax identification to aproach to exclusion based regex

* Linter fix

* The actual linter fix

* E2E fix

* Fixed dokcerfile lib from statement function LineHint value so multiline FROM statements are compatible, fixed whitespace support for ARG/comments in dockerfiles and fix new E2E results

* Fix E2E 107

* fix changed files to pre-rebase state

* Fixed value attribution that should have been comparison

* bug(security): fix security vulnerability findings (#8084)

* fix insecure temp file

* fix insecure temp file perms

* add path traversal sanitation

* add path traversal sanitization

* add path traversal sanitization tests

* add path traversal sanitization e2e tests

* add path traversal sanitization e2e tests

* fix lint issues

* fix secrets inspector possible resource exhaustion

* fix secrets line detection for end of document specific case

* bump deps and actions versions

* bump deps and actions versions

* [StepSecurity] Apply security best practices (#8060)

Signed-off-by: StepSecurity Bot <bot@stepsecurity.io>
Co-authored-by: stepsecurity-app[bot] <188008098+stepsecurity-app[bot]@users.noreply.github.com>

* [StepSecurity] Apply security best practices (#8063)

Signed-off-by: StepSecurity Bot <bot@stepsecurity.io>
Co-authored-by: stepsecurity-app[bot] <188008098+stepsecurity-app[bot]@users.noreply.github.com>

* chore: remove Dependabot configuration

* Remove old SBOM (#8071)

Signed-off-by: Yevgeny Kuznetsov <yevgeny.kuznetsov@checkmarx.com>

* fix(vulnerabilities): update dockerfile and fix trivy vulnerabilities (#8076)

* update: dockerfile and fix vulnerabilities

* update: dockerfile with arguments before both FROM for universal scope

* update: vulnerable packages and dockerfile images

* ci: trigger

* fix: dockerfile deprecation notice for LegacyKeyValueFormat

---------

Signed-off-by: StepSecurity Bot <bot@stepsecurity.io>
Signed-off-by: Yevgeny Kuznetsov <yevgeny.kuznetsov@checkmarx.com>
Co-authored-by: cx-miguel-silva <100352574+cx-miguel-silva@users.noreply.github.com>
Co-authored-by: stepsecurity-app[bot] <188008098+stepsecurity-app[bot]@users.noreply.github.com>
Co-authored-by: Ohad Israeli <243351248+cx-ohad-israeli@users.noreply.github.com>
Co-authored-by: Yevgeny Kuznetsov <yevgeny.kuznetsov@checkmarx.com>
Co-authored-by: Artur Ribeiro <153724638+cx-artur-ribeiro@users.noreply.github.com>

* fix(parser): fixed looping behavior triggered during dockerfile parsing  (#8085)

* fixs for ast 154904, loop on RUN commands and 2 unrelated queries changed

* Fixed unnecessary space affecting distance calculation/ line in vulnerability result

* Update packages again

* fix(query): updated "SQL DB Instance With SSL Disabled" Terraform query to handle 'require_ssl' field deprecation  (#8029)

* First commit: udpated query to handle deprecation of 'require_ssl' field, support for all 'ssl_mode' field values, new tests and metadata Url updated

* Small change to comments for consistency sake

* New samples and auxiliary functions to properly handle SQLSERVER databases (do not support 'TRUSTED_CLIENT_CERTIFICATE_REQUIRED' value

* Expected values and some test changes

* Fix expected results again

---------

Co-authored-by: Alon Rosenhek <80337069+cx-alon-rosenhek@users.noreply.github.com>

* fix(query): the "Image Version Using Latest" dockerfile query was not accounting for specific digest values (#8033)

* Fix check for ':latest' to ensure it is used as a sufix on the image reference (no @sha...)

* feat(tests): improving E2E HTML report and output on remediation tests (#7955)

* first commit

* rewrite previous changes

* causing remediation error on purpose

* some changes

* .

* .

* added remediatedFiles to error output in remediation tests

* restored directories removed by mistake

* removed files

* Delete assets/queries/terraform/aws/api_gateway_access_logging_disabled/payloads/all_payloads.json

* Delete assets/queries/terraform/aws/sns_topic_is_publicly_accessible/payloads/all_payloads.json

* Delete assets/queries/terraform/aws/sns_topic_is_publicly_accessible/payloads directory

* Delete assets/queries/terraform/aws/sns_topic_is_publicly_accessible/samples/sample.tf

* Delete assets/queries/terraform/gcp/ensure_essential_contacts_is_configured_for_organization/payloads/all_payloads.json

* Delete assets/queries/terraform/gcp/ensure_essential_contacts_is_configured_for_organization/payloads directory

* Delete assets/queries/terraform/gcp/ensure_gke_version_management_is_automated_using_release_channels/payloads/all_payloads.json

* Delete assets/queries/terraform/gcp/ensure_gke_version_management_is_automated_using_release_channels/payloads directory

* Delete assets/queries/terraform/gcp/google_kubernetes_engine_cluster_have_alpha_features_enabled/payloads/all_payloads.json

* Delete assets/queries/terraform/gcp/legacy_networks_do_not_exist_for_older_google_projects/payloads/test_payload.json

* Delete assets/queries/terraform/gcp/legacy_networks_do_not_exist_for_older_google_projects/payloads directory

* Delete assets/queries/terraform/gcp/logs_and_alerts_missing_audit_configuration_changes/payloads/all_payloads.json

* Delete assets/queries/terraform/gcp/logs_and_alerts_missing_audit_configuration_changes/payloads directory

* Delete assets/queries/terraform/gcp/logs_and_alerts_missing_custom_role_changes/test/test.tf

* Delete assets/queries/terraform/gcp/logs_and_alerts_missing_custom_role_changes/payloads directory

* Delete assets/queries/terraform/gcp/logs_and_alerts_missing_project_ownership_assignment_and_changes/payloads/positive1_payload.json

* Delete assets/queries/terraform/gcp/logs_and_alerts_missing_project_ownership_assignment_and_changes/payloads directory

* Delete assets/queries/terraform/gcp/shielded_gke_node_do_not_have_integrity_monitoring_enabled/payloads/all_payloads.json

* Delete assets/queries/terraform/gcp/shielded_gke_node_do_not_have_integrity_monitoring_enabled/payloads directory

* Delete assets/queries/terraform/gcp/sql_db_instance_external_scripts_enabled/test/negative.tf

* Delete assets/queries/terraform/gcp/sql_db_instance_external_scripts_enabled/test directory

* Delete assets/queries/terraform/gcp/sql_db_instance_external_scripts_enabled directory

* added remediation problems to the query

* fixed golint problems

* golint

* change on the query

* fixing line that surpasses the 140 characters limits by go-ci/lint

* .

* changed e2e test to see HTML results output

* .

* .

* .

* removed one query in the results

* indenting json output on E2E test HTML report

* changed fixture results

* changed comparison using listA and list B, to Expected and Actual lists

* some changes on the json output

* reverted changes on E2E results outputs

* put listA and listB side by side

* fully implemented red line for diff line

* added queryName in the output

* final improvement on HTML E2E test results output

* removed unnecessary comment

* revert changes made on E2E fixtures

* reverted changes on E2E files

* reverted changes on E2E files

* reverted changes on the wrong go template file

* fixing go lint errors

* fixing go lint error

* go lint error fixing

* go lint error fixing

* go lint error fixing

* fixing go lint errors

* fixing go lint errors

* fixing go lint errors

* fixing go lint errors

* fixing go lint errors

* fixing go lint errors

* keeping up with the codacy quality standards

* improvements on the code

* trimmed lines before direct comparisons

* adding the e2e-report file again

* changing google.golang.org/grpc version from 1.77.0 to 1.79.3

* fixed analyze command in e2e test

* covered FileStats field comparison on e2e tests

* reverting changes made on analyze.go file

* changed moby/buildkit version from 0.26.3 to 0.28.1

* revert changes

* changed moby/buildkit version from 0.26.3 to 0.28.1

* fixing unproperly formatted code

* fixed path

* fixed unproperly formatted code

* removed commented code

* fixed some E2E tests not showing the intended output format

* final fix for the tests that are currently without the proper HTML report output format

* changing code to reduce cyclomatic complexity

* fixing code to be properly formatted

* removed unnecessary printf's

* fixing the code using gofmt

* changed github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream and github.com/aws/aws-sdk-go-v2/service/s3 version in go.mod

---------

Co-authored-by: Artur Ribeiro <153724638+cx-artur-ribeiro@users.noreply.github.com>

* fix(workflows): update github actions to use SHA (#8035)

* Update github action to use SHA

* Update vulnerable dependency

* Update dockerfiles to use go 1.26.2

* Rollback go.mod to 1.25.5

* Fix vulnerabilities

* Fix vulnerabilities

* Update go version

* Suppress vulnerability

* Update dockerfile

* Update .grype.yaml

Co-authored-by: Rui Araújo Gomes <110477212+cx-rui-araujo@users.noreply.github.com>

* Small update

---------

Co-authored-by: Rui Araújo Gomes <110477212+cx-rui-araujo@users.noreply.github.com>

* feat(action): added validation for searchLine field in actions (#7994)

* changed go-ci.yml to use a script to check searchLine

* .

* fixed print to not use f when is missing placeholders

* removed unnecessary action

* fixed typo

* fixing issues from codacy

* updated go image in Dockerfile

* update go images

* changed git image

* changing positive expected results

* added requests to requirements file

* changed searchLine to get -1 value

* added debug prints

* added exception type

* fixing error in script

* removed trailing whitespace

* changed to run the other script

* debugging test directory path

* changed scripts that run on the action

* removed f-string without placeholders

* inverted changes on the query

* changed positive_expected_result

* changed filename to fileName

* added print for debugging processes

* added print to see content value

* changed script

* testing searchLine != searchLine

* removed unnecessary sorting on the results in execution context

* removed unused requirements.txt file

* reverter changes on positie_expected_results

* changes on the script and removed unnecessary go setup

* changed query to get errors on go-ci action

* parsing json data into objects

* small change to test if this is the root of the problem

* reverted changes

* fixing misspelled directory name

* fixing some errors in the script used in the validate-search-line job in go-ci action

* fixed misspelled field in validate_scan_results function

* simplifying code

* using pymarshal to use models that unmarshal json content directly

* fixing errors in results_models pymarshal import

* testing searchLine defined to '-1' hardcoded value

* convert line and searchLine to int

* adding print's for debug purposes

* adding print's for debug purposes

* fixing cases where searchLine is defined to an hardcoded value of -1

* added prints for debug purposes

* debug prints

* debug prints

* debug prints

* changes for debug purposes

* .

* changes

* trying to fix cases with -1 hardcoded on searchLine

* changes

* more changes

* trying type_assert

* trying type_assert

* trying type_assert

* trying type_assert

* trying type_assert

* testing new scenario

* testing test3 case from artur test branch

* testing test3 case from artur test branch

* back to the other scenario

* back to the other scenario again

* used unmarshal_json from pumarshal to unmarshal the json with the results

* testing hardcoded .1 again

* trying case - common_lib.build_search_line([shdfosdhfoisdhf], []),

* reverting changes on dockerfiles

* removed the usage of type_assert to be more permissive about fields not defined on the results file

* changed to see other case output in the actions

* added field queries_failed_to_execute

* changing query searchLine field to test another scenario

* changed to another scenario

* reverting changes made on the query

* changed to test scenario when "searchLine": common_lib.build_search_line(["potatos"], [])

* testing scenario where searchLine is defined to '-1'

* removed unnecessary pymarshal pip instalation

* testing another scenario

* testing searchLine defined to '-1'

* testing searchLine defined to 'potatos'

* reverting query changezs

* reverting changes on query

* reverting changes on docker files

* reverting changes on dockerfiles

* removed \n

* adding debug prints to see the output from variables produced by dorny/path

* added \n

* added echo for debug purposes

* Reverting changes on Dockerfile

* adding print on script

* testing outcome

* using Set Up python step outcome value to define if validate search line in modified queries runs or not

* changing go-jose version

* changing script code to match Codacy best practices

* changing code to comply with the Codacy quality standards

* changing go.mod

* fixing Codacy issues

* changing Go and Git images on Dockerfile

* changing go.mod

* reverting changes on go.mod

* changing go version

* fixing scripts according to Codacy issues

* fixing script to be up to the Codacy quality standards

* fixing Codacy issues

* fixing Codacy issues

* fixing Codacy issues

* fixing D212 in validate_search_line.py file

* reverting changes to fix D212

---------

Co-authored-by: Artur Ribeiro <153724638+cx-artur-ribeiro@users.noreply.github.com>

* Change to use actions role (#8040)

* Change to use actions role

* Update run-projects.yaml

* ci(secrets): use aws oidc (#8041)

* ci: fix aws secrets

* ci: fix permissions

* ci: remove audience

* ci: test gh token

* ci: use sha

* fix(query): fix FP results on "IAM policy allows for data exfiltration" CloudFormation and Terraform queries (#8030)

* Added missing check/associated tests to cloudFormation and Terraform iam_policy data exfiltration queries

---------

Co-authored-by: Artur Ribeiro <153724638+cx-artur-ribeiro@users.noreply.github.com>

* [StepSecurity] Apply security best practices (#8060)

Signed-off-by: StepSecurity Bot <bot@stepsecurity.io>
Co-authored-by: stepsecurity-app[bot] <188008098+stepsecurity-app[bot]@users.noreply.github.com>

* [StepSecurity] Apply security best practices (#8063)

Signed-off-by: StepSecurity Bot <bot@stepsecurity.io>
Co-authored-by: stepsecurity-app[bot] <188008098+stepsecurity-app[bot]@users.noreply.github.com>

* chore: remove Dependabot configuration

* Remove old SBOM (#8071)

Signed-off-by: Yevgeny Kuznetsov <yevgeny.kuznetsov@checkmarx.com>

* fix(vulnerabilities): update dockerfile and fix trivy vulnerabilities (#8076)

* update: dockerfile and fix vulnerabilities

* update: dockerfile with arguments before both FROM for universal scope

* update: vulnerable packages and dockerfile images

* ci: trigger

* fix: dockerfile deprecation notice for LegacyKeyValueFormat

* bug(security): fix security vulnerability findings (#8084)

* fix insecure temp file

* fix insecure temp file perms

* add path traversal sanitation

* add path traversal sanitization

* add path traversal sanitization tests

* add path traversal sanitization e2e tests

* add path traversal sanitization e2e tests

* fix lint issues

* fix secrets inspector possible resource exhaustion

* fix secrets line detection for end of document specific case

* bump deps and actions versions

* bump deps and actions versions

* [StepSecurity] Apply security best practices (#8060)

Signed-off-by: StepSecurity Bot <bot@stepsecurity.io>
Co-authored-by: stepsecurity-app[bot] <188008098+stepsecurity-app[bot]@users.noreply.github.com>

* [StepSecurity] Apply security best practices (#8063)

Signed-off-by: StepSecurity Bot <bot@stepsecurity.io>
Co-authored-by: stepsecurity-app[bot] <188008098+stepsecurity-app[bot]@users.noreply.github.com>

* chore: remove Dependabot configuration

* Remove old SBOM (#8071)

Signed-off-by: Yevgeny Kuznetsov <yevgeny.kuznetsov@checkmarx.com>

* fix(vulnerabilities): update dockerfile and fix trivy vulnerabilities (#8076)

* update: dockerfile and fix vulnerabilities

* update: dockerfile with arguments before both FROM for universal scope

* update: vulnerable packages and dockerfile images

* ci: trigger

* fix: dockerfile deprecation notice for LegacyKeyValueFormat

---------

Signed-off-by: StepSecurity Bot <bot@stepsecurity.io>
Signed-off-by: Yevgeny Kuznetsov <yevgeny.kuznetsov@checkmarx.com>
Co-authored-by: cx-miguel-silva <100352574+cx-miguel-silva@users.noreply.github.com>
Co-authored-by: stepsecurity-app[bot] <188008098+stepsecurity-app[bot]@users.noreply.github.com>
Co-authored-by: Ohad Israeli <243351248+cx-ohad-israeli@users.noreply.github.com>
Co-authored-by: Yevgeny Kuznetsov <yevgeny.kuznetsov@checkmarx.com>
Co-authored-by: Artur Ribeiro <153724638+cx-artur-ribeiro@users.noreply.github.com>

* Requested change

* update images and pacakges for vulnerabilities

* bump compress to 1.18.7

---------

Signed-off-by: StepSecurity Bot <bot@stepsecurity.io>
Signed-off-by: Yevgeny Kuznetsov <yevgeny.kuznetsov@checkmarx.com>
Co-authored-by: Ricardo Jesus <219317970+cx-ricardo-jesus@users.noreply.github.com>
Co-authored-by: Artur Ribeiro <153724638+cx-artur-ribeiro@users.noreply.github.com>
Co-authored-by: Bruno Silva <73999905+cx-bruno-silva@users.noreply.github.com>
Co-authored-by: Rui Araújo Gomes <110477212+cx-rui-araujo@users.noreply.github.com>
Co-authored-by: João Reigota <74597872+cx-joao-reigota@users.noreply.github.com>
Co-authored-by: Rafael Carvalho <153817659+cx-rafael-carvalho@users.noreply.github.com>
Co-authored-by: stepsecurity-app[bot] <188008098+stepsecurity-app[bot]@users.noreply.github.com>
Co-authored-by: Ohad Israeli <243351248+cx-ohad-israeli@users.noreply.github.com>
Co-authored-by: Yevgeny Kuznetsov <yevgeny.kuznetsov@checkmarx.com>
Co-authored-by: Miguel da Silva <100352574+cx-miguel-dasilva@users.noreply.github.com>
Co-authored-by: cx-miguel-silva <100352574+cx-miguel-silva@users.noreply.github.com>

* updated query to support parameters (#8086)

* fix(queries): fixed FN on run/script block injection query for github/cicd (#8089)

* added coverage for github.event.comment.user.login in issue_comment event type

* added coverage for some pattern in push events in Run Block Injection query

* added coverage for some pattern in push events in Script Block Injection query

* added pattern that was only covered by the run block injection query

* fix(query): fixed FP for sql server database without auditing for arm (#8087)

* added new case on the negative tests

* updating query

---------

Co-authored-by: Alon Rosenhek <80337069+cx-alon-rosenhek@users.noreply.github.com>

* fix(query): fix FP on unpinned package version in pip install for dockerfile (#8090)

* solved specific FP for RUN commands with multiple flags with arguments

* added new test samples

* covered the scenarios where there is a RUN command with a list

* Re added changes that were undone during rebase / force push

* renamed tests and changed expected results to accomodate for PR 8099

* Fixed unppinned package version in pip install expected results

* E2E fixed, fix to query changed expected results, changed sample to start flagging again with said query, adjusted E2E naming so 106 from this PR is 108 (anotehr 106 was introduced and merged with master)

* minor E2E change for consistency

* Request documentation change + adjusted all samples to include count value 1 when there are multiple positive/negative samples which inludes all dockerfile queries now

* Fix for my newly added E2E tests (missed a .. that should have been /path) and adjusted E2E 25 that mentioned positive test that is now positive1

* Fix for second policy on run_using_sudo query + samples that actually test the CxPolicy that regressed + fix for existing issue that caused query to point to 'FROM' statement instead of target SUDO command (run_value sanitize)

* Fix expected results

---------

Signed-off-by: StepSecurity Bot <bot@stepsecurity.io>
Signed-off-by: Yevgeny Kuznetsov <yevgeny.kuznetsov@checkmarx.com>
Co-authored-by: Artur Ribeiro <153724638+cx-artur-ribeiro@users.noreply.github.com>
Co-authored-by: Miguel da Silva <100352574+cx-miguel-dasilva@users.noreply.github.com>
Co-authored-by: cx-miguel-silva <100352574+cx-miguel-silva@users.noreply.github.com>
Co-authored-by: Eli Shalnev <205644192+cx-eli-shalnev@users.noreply.github.com>
Co-authored-by: Ricardo Jesus <219317970+cx-ricardo-jesus@users.noreply.github.com>
Co-authored-by: Bruno Silva <73999905+cx-bruno-silva@users.noreply.github.com>
Co-authored-by: Rui Araújo Gomes <110477212+cx-rui-araujo@users.noreply.github.com>
Co-authored-by: João Reigota <74597872+cx-joao-reigota@users.noreply.github.com>
Co-authored-by: Rafael Carvalho <153817659+cx-rafael-carvalho@users.noreply.github.com>
Co-authored-by: stepsecurity-app[bot] <188008098+stepsecurity-app[bot]@users.noreply.github.com>
Co-authored-by: Ohad Israeli <243351248+cx-ohad-israeli@users.noreply.github.com>
Co-authored-by: Yevgeny Kuznetsov <yevgeny.kuznetsov@checkmarx.com>
Co-authored-by: Alon Rosenhek <80337069+cx-alon-rosenhek@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community Community contribution docker Docker query dockerfile query New query feature workflows-approved

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants