From f1b287068c7ae42f9ce49e497086cab41e0d734c Mon Sep 17 00:00:00 2001 From: AllanZhengYP Date: Mon, 28 Nov 2022 16:05:24 -0800 Subject: [PATCH 1/8] chore: create codeql workflow CodeQL sanning will replace deprecating LGTM --- .github/workflows/codeql.yml | 74 ++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 .github/workflows/codeql.yml diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 00000000000..c25f8070cf8 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,74 @@ +# 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: [ "main", 1.0-stable, 2.0-stable, alpha, next-major-version/*, release, releases, v4-stable ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ "main" ] + schedule: + - cron: '19 20 * * 2' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ '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#, Go, 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 + with: + category: "/language:${{matrix.language}}" From c94b6801c2b679870da996139e0841250a06f39b Mon Sep 17 00:00:00 2001 From: Allan Zheng Date: Mon, 28 Nov 2022 17:10:23 -0800 Subject: [PATCH 2/8] chore: run codeql on all commits --- .github/workflows/codeql.yml | 65 +++++++++++++++++------------------- 1 file changed, 31 insertions(+), 34 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index c25f8070cf8..a7401a0ef06 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -9,16 +9,14 @@ # the `language` matrix defined below to confirm you have the correct set of # supported CodeQL languages. # -name: "CodeQL" +name: 'CodeQL' on: push: - branches: [ "main", 1.0-stable, 2.0-stable, alpha, next-major-version/*, release, releases, v4-stable ] + branches: '*' pull_request: # The branches below must be a subset of the branches above - branches: [ "main" ] - schedule: - - cron: '19 20 * * 2' + branches: ['main', 'release', '**/main'] jobs: analyze: @@ -32,43 +30,42 @@ jobs: strategy: fail-fast: false matrix: - language: [ 'javascript' ] + language: ['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 + - 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. + # 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 + # 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#, Go, 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 - # Autobuild attempts to build any compiled languages (C/C++, C#, Go, 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 - # ℹī¸ 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. - # 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 - # - run: | - # echo "Run, Build Application using script" - # ./location_of_script_within_repo/buildscript.sh - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 - with: - category: "/language:${{matrix.language}}" + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 + with: + category: '/language:${{matrix.language}}' From 5fafc5f67874bf8f60eeada7ad3a2c3401fbfd90 Mon Sep 17 00:00:00 2001 From: Allan Zheng Date: Mon, 28 Nov 2022 22:41:10 -0800 Subject: [PATCH 3/8] chore: test for prs on codeql-* branchs --- .github/workflows/codeql.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index a7401a0ef06..287db7a129c 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -16,7 +16,7 @@ on: branches: '*' pull_request: # The branches below must be a subset of the branches above - branches: ['main', 'release', '**/main'] + branches: ['main', 'release', '**/main', 'codeql-*'] jobs: analyze: From bb6e815bbbc5eb1e25fd193fb1043446f8884db9 Mon Sep 17 00:00:00 2001 From: Allan Zheng Date: Tue, 29 Nov 2022 13:40:02 -0800 Subject: [PATCH 4/8] chore: enable codeql on all push and prs --- .github/workflows/codeql.yml | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 287db7a129c..5ccb7ea40a7 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -1,22 +1,8 @@ -# 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: '*' pull_request: - # The branches below must be a subset of the branches above - branches: ['main', 'release', '**/main', 'codeql-*'] jobs: analyze: @@ -37,6 +23,9 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v3 + with: + # Minimal depth 2 so we can checkout the commit before possible merge commit. + fetch-depth: 2 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL From 45ca9a81d080e6fcfc89f2893f1ebef2cca153d1 Mon Sep 17 00:00:00 2001 From: Allan Zheng Date: Tue, 29 Nov 2022 14:02:34 -0800 Subject: [PATCH 5/8] chore: ignore docs and tests in the codeql --- .github/codeql/codeql-config.yml | 4 ++++ .github/workflows/codeql.yml | 1 + 2 files changed, 5 insertions(+) create mode 100644 .github/codeql/codeql-config.yml diff --git a/.github/codeql/codeql-config.yml b/.github/codeql/codeql-config.yml new file mode 100644 index 00000000000..13a9a28cd8c --- /dev/null +++ b/.github/codeql/codeql-config.yml @@ -0,0 +1,4 @@ +paths-ignore: + - 'packages/*/__tests__' + - 'packages/*/__mocks__' + - docs/ diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 5ccb7ea40a7..274cdf7d339 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -32,6 +32,7 @@ jobs: uses: github/codeql-action/init@v2 with: languages: ${{ matrix.language }} + config-file: ./.github/codeql/codeql-config.yml # 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. From a98a56941c7680e6fb09d784d9353d0e2b81d526 Mon Sep 17 00:00:00 2001 From: Allan Zheng Date: Tue, 29 Nov 2022 14:21:33 -0800 Subject: [PATCH 6/8] chore: add unit test folder to code scan --- .github/codeql/codeql-config.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/codeql/codeql-config.yml b/.github/codeql/codeql-config.yml index 13a9a28cd8c..2d8a2733604 100644 --- a/.github/codeql/codeql-config.yml +++ b/.github/codeql/codeql-config.yml @@ -1,4 +1,2 @@ paths-ignore: - - 'packages/*/__tests__' - - 'packages/*/__mocks__' - docs/ From de498e05f49f77e6932ef300d74fce2a4cc43252 Mon Sep 17 00:00:00 2001 From: Allan Zheng Date: Tue, 29 Nov 2022 15:05:44 -0800 Subject: [PATCH 7/8] chore: disable codescan on react native docs --- .github/codeql/codeql-config.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/codeql/codeql-config.yml b/.github/codeql/codeql-config.yml index 2d8a2733604..17032e3abd6 100644 --- a/.github/codeql/codeql-config.yml +++ b/.github/codeql/codeql-config.yml @@ -1,2 +1,3 @@ paths-ignore: - - docs/ + - docs + - packages/aws-amplify-react-native/docs From a7b7dc6990db69064585d1d3bbe85c1fa7dbe463 Mon Sep 17 00:00:00 2001 From: Allan Zheng Date: Tue, 29 Nov 2022 16:31:23 -0800 Subject: [PATCH 8/8] chore: remove excessive comments from the codeql.yml --- .github/workflows/codeql.yml | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 274cdf7d339..b3472e6d096 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -1,3 +1,4 @@ +# Ref: https://tinyurl.com/5d6rr8s7 name: 'CodeQL' on: @@ -17,8 +18,6 @@ jobs: fail-fast: false matrix: language: ['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 @@ -33,28 +32,11 @@ jobs: with: languages: ${{ matrix.language }} config-file: ./.github/codeql/codeql-config.yml - # 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#, Go, 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 with: