diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml deleted file mode 100644 index 70fbf787..00000000 --- a/.github/workflows/codeql-analysis.yml +++ /dev/null @@ -1,72 +0,0 @@ -# For most projects, this workflow file will not need changing; you simply need -# to commit it to your repository. -# -# You may wish to alter this file to override the set of languages analyzed, -# or to provide custom queries or build logic. -# -# ******** NOTE ******** -# We have attempted to detect the languages in your repository. Please check -# the `language` matrix defined below to confirm you have the correct set of -# supported CodeQL languages. -# -name: "CodeQL" - -on: - push: - branches: [ "master" ] - pull_request: - # The branches below must be a subset of the branches above - branches: [ "master" ] - schedule: - - cron: '30 12 * * 6' - -jobs: - analyze: - name: Analyze - runs-on: ubuntu-latest - permissions: - actions: read - contents: read - security-events: write - - strategy: - fail-fast: false - matrix: - language: [ 'java', 'javascript' ] - # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] - # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v2 - with: - languages: ${{ matrix.language }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. - - # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs - # queries: security-extended,security-and-quality - - - # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v2 - - # â„šī¸ Command-line programs to run using the OS shell. - # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun - - # If the Autobuild fails above, remove it and uncomment the following three lines. - # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. - - # - run: | - # echo "Run, Build Application using script" - # ./location_of_script_within_repo/buildscript.sh - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 1ac78230..454d17dd 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -27,6 +27,12 @@ jobs: distribution: 'temurin' java-version: '8' cache: 'maven' + + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: java, javascript + - name: Build with Maven run: cd stackrox-container-image-scanner && ./mvnw -B verify package hpi:hpi cyclonedx:makeAggregateBom - uses: actions/upload-artifact@v3 @@ -34,6 +40,9 @@ jobs: name: stackrox-container-image-scanner.hpi path: stackrox-container-image-scanner/target/stackrox-container-image-scanner.hpi + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 + e2e: runs-on: ubuntu-latest needs: build @@ -91,14 +100,6 @@ jobs: ./deploy/k8s/central.sh pass=$(cat deploy/k8s/central-deploy/password) echo "ROX_PASSWORD=$(cat deploy/k8s/central-deploy/password)" >> $GITHUB_OUTPUT - - name: Run proxy - env: - port: 8000 - run: | - pid="$(lsof -n -i "tcp:${port}" | grep kubectl | awk '{print $2}' | uniq)" - [[ -n "${pid}" ]] || { einfo "No kubectl port-forward is running on port ${port}."; exit 0; } - kill "${pid}" || die "Kill failed" - kubectl port-forward -n 'stackrox' svc/central "8000:443" --address='0.0.0.0' & - name: Wait for API run: | cd stackrox diff --git a/functionaltest-jenkins-plugin/src/test/groovy/ImageScanningTest.groovy b/functionaltest-jenkins-plugin/src/test/groovy/ImageScanningTest.groovy index 98eb22da..ec80a9f5 100644 --- a/functionaltest-jenkins-plugin/src/test/groovy/ImageScanningTest.groovy +++ b/functionaltest-jenkins-plugin/src/test/groovy/ImageScanningTest.groovy @@ -20,9 +20,14 @@ import spock.lang.Unroll class ImageScanningTest extends BaseSpecification { protected static final String CENTRAL_URI = Config.centralUri + protected static final String QUAY_REPO = "quay.io/openshifttest/" @Unroll def "image scanning test with toggle enforcement(#imageName, #policyName, #enforcements, #endStatus)"() { + given: + updatePolicy("Fixable CVSS >= 7", "latest", []) + updatePolicy("Fixable Severity at least Important", "latest", []) + when: StoragePolicy enforcementPolicy = updatePolicy(policyName, "latest", enforcements) @@ -39,9 +44,9 @@ class ImageScanningTest extends BaseSpecification { where: "data inputs are: " - imageName | policyName | enforcements | endStatus - "nginx:latest" | "Latest tag" | [] | SUCCESS - "nginx:latest" | "Latest tag" | [FAIL_BUILD_ENFORCEMENT] | FAILURE + imageName | policyName | enforcements | endStatus + "nginx-alpine:latest" | "Latest tag" | [] | SUCCESS + "nginx-alpine:latest" | "Latest tag" | [FAIL_BUILD_ENFORCEMENT] | FAILURE } @Unroll @@ -63,9 +68,9 @@ class ImageScanningTest extends BaseSpecification { where: "data inputs are: " - imageName | policyName | tag - "jenkins/jenkins:2.77" | "Fixable CVSS >= 7" | "2.77" - "nginx:latest" | "Latest tag" | "latest" + imageName | policyName | tag + "nginx-alpine:1.2.1" | "Fixable CVSS >= 7" | "1.2.1" + "nginx-alpine:latest" | "Latest tag" | "latest" } @Unroll @@ -79,14 +84,14 @@ class ImageScanningTest extends BaseSpecification { where: "data inputs are: " - imageName | failOnCriticalPluginError | endStatus - "postgres:latest" | true | SUCCESS - "mis-spelled:lts" | true | FAILURE - "mis-spelled:lts" | false | SUCCESS + imageName | failOnCriticalPluginError | endStatus + "nginx-alpine:latest" | true | SUCCESS + "mis-spelled:lts" | true | FAILURE + "mis-spelled:lts" | false | SUCCESS } String getJobConfig(String imageName, Boolean policyEvalCheck, Boolean failOnCriticalPluginError) { - return createJobConfig(imageName, CENTRAL_URI, token, policyEvalCheck, failOnCriticalPluginError) + return createJobConfig(QUAY_REPO + imageName, CENTRAL_URI, token, policyEvalCheck, failOnCriticalPluginError) } StoragePolicy updatePolicy(String policyName, String tag, List enforcements) { diff --git a/functionaltest-jenkins-plugin/src/test/groovy/ImageScanningTestNoFileTest.groovy b/functionaltest-jenkins-plugin/src/test/groovy/ImageScanningTestNoFileTest.groovy index 5c2cc9db..2de63299 100644 --- a/functionaltest-jenkins-plugin/src/test/groovy/ImageScanningTestNoFileTest.groovy +++ b/functionaltest-jenkins-plugin/src/test/groovy/ImageScanningTestNoFileTest.groovy @@ -3,6 +3,7 @@ import static JenkinsClient.createJobConfigNoFile class ImageScanningTestNoFileTest extends ImageScanningTest { @Override String getJobConfig(String imageName, Boolean policyEvalCheck, Boolean failOnCriticalPluginError) { - return createJobConfigNoFile(imageName, CENTRAL_URI, token, policyEvalCheck, failOnCriticalPluginError) + String image = QUAY_REPO + imageName + return createJobConfigNoFile(image, CENTRAL_URI, token, policyEvalCheck, failOnCriticalPluginError) } }