From 95d20c4ac82d36f9f8a4f38460bc4c1fbb6793bf Mon Sep 17 00:00:00 2001 From: Timothee Guerin Date: Wed, 28 Feb 2024 08:38:58 -0800 Subject: [PATCH 1/5] Fix crash with duplicate paths --- packages/libs/deduplication/src/main.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/libs/deduplication/src/main.ts b/packages/libs/deduplication/src/main.ts index 9c0e6c29ec..3af8f88182 100644 --- a/packages/libs/deduplication/src/main.ts +++ b/packages/libs/deduplication/src/main.ts @@ -192,8 +192,7 @@ export class Deduplicator { let filename = path[xMsMetadata].filename; let originalLocations = path[xMsMetadata].originalLocations; const pathFromMetadata = path[xMsMetadata].path; - let profiles = path[xMsMetadata].profiles; - + let profiles = path[xMsMetadata].profiles ?? {}; // extract path properties excluding metadata const { "x-ms-metadata": metadataCurrent, ...filteredPath } = path; @@ -218,7 +217,7 @@ export class Deduplicator { originalLocations = originalLocations.concat(anotherPath[xMsMetadata].originalLocations); profiles = getMergedProfilesMetadata( profiles, - anotherPath[xMsMetadata].profiles, + anotherPath[xMsMetadata].profiles ?? {}, path[xMsMetadata].path, originalLocations, ); From 80b59bb703c57bfacaf5304793d2d2fb15586ce5 Mon Sep 17 00:00:00 2001 From: Timothee Guerin Date: Wed, 28 Feb 2024 08:43:52 -0800 Subject: [PATCH 2/5] Fix --- ...fix-crash-duplicate-path_2024-02-28-16-43 copy.json | 10 ++++++++++ .../fix-crash-duplicate-path_2024-02-28-16-43.json | 10 ++++++++++ 2 files changed, 20 insertions(+) create mode 100644 common/changes/@azure-tools/deduplication/fix-crash-duplicate-path_2024-02-28-16-43 copy.json create mode 100644 common/changes/@azure-tools/deduplication/fix-crash-duplicate-path_2024-02-28-16-43.json diff --git a/common/changes/@azure-tools/deduplication/fix-crash-duplicate-path_2024-02-28-16-43 copy.json b/common/changes/@azure-tools/deduplication/fix-crash-duplicate-path_2024-02-28-16-43 copy.json new file mode 100644 index 0000000000..95ca34743d --- /dev/null +++ b/common/changes/@azure-tools/deduplication/fix-crash-duplicate-path_2024-02-28-16-43 copy.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@autorest/core", + "comment": "Fix: Crash when deduplication paths", + "type": "patch" + } + ], + "packageName": "@autorest/core" +} diff --git a/common/changes/@azure-tools/deduplication/fix-crash-duplicate-path_2024-02-28-16-43.json b/common/changes/@azure-tools/deduplication/fix-crash-duplicate-path_2024-02-28-16-43.json new file mode 100644 index 0000000000..b24a859a6a --- /dev/null +++ b/common/changes/@azure-tools/deduplication/fix-crash-duplicate-path_2024-02-28-16-43.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@azure-tools/deduplication", + "comment": "Fix: Crash when deduplication paths", + "type": "patch" + } + ], + "packageName": "@azure-tools/deduplication" +} \ No newline at end of file From 2d52281adb5e6d6239c98a49af56a19db1ae6e43 Mon Sep 17 00:00:00 2001 From: Timothee Guerin Date: Wed, 28 Feb 2024 08:53:58 -0800 Subject: [PATCH 3/5] Tweak --- packages/extensions/core/src/app.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/extensions/core/src/app.ts b/packages/extensions/core/src/app.ts index bed4996c26..693dd41168 100644 --- a/packages/extensions/core/src/app.ts +++ b/packages/extensions/core/src/app.ts @@ -351,7 +351,9 @@ async function main() { // - doing the inversion (instanceof Error) doesn't reliably work since that seems to return false on Errors marshalled from safeEval if (e instanceof Exception) { logger.log({ level: "error", message: e.message }); - exitCode = e.exitCode; + if (e.exitCode) { + exitCode = e.exitCode; + } } if (e !== false) { logger.log({ level: "error", message: `!${e}` }); From 0b02b26be872395fa7c1d2593be761bdad8387f1 Mon Sep 17 00:00:00 2001 From: Timothee Guerin Date: Wed, 28 Feb 2024 08:56:40 -0800 Subject: [PATCH 4/5] . --- .../fix-crash-duplicate-path_2024-02-28-16-43 copy.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/common/changes/@azure-tools/deduplication/fix-crash-duplicate-path_2024-02-28-16-43 copy.json b/common/changes/@azure-tools/deduplication/fix-crash-duplicate-path_2024-02-28-16-43 copy.json index 95ca34743d..2d5bbc09d2 100644 --- a/common/changes/@azure-tools/deduplication/fix-crash-duplicate-path_2024-02-28-16-43 copy.json +++ b/common/changes/@azure-tools/deduplication/fix-crash-duplicate-path_2024-02-28-16-43 copy.json @@ -4,6 +4,11 @@ "packageName": "@autorest/core", "comment": "Fix: Crash when deduplication paths", "type": "patch" + }, + { + "packageName": "@autorest/core", + "comment": "Fix: Crash reporting zero exit code when a plugin report a crash but send invalid exception", + "type": "patch" } ], "packageName": "@autorest/core" From 6dc6f29895426b30e84e8138101372a76f0c24b2 Mon Sep 17 00:00:00 2001 From: Timothee Guerin Date: Wed, 28 Feb 2024 08:58:58 -0800 Subject: [PATCH 5/5] fix codeql --- .github/workflows/codeql.yml | 76 ++++++++++++++++++++++-------------- 1 file changed, 47 insertions(+), 29 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 8e08852ab7..6f749caff8 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -1,51 +1,69 @@ -name: "Code scanning - action" +name: "CodeQL" on: push: + branches: ["main", "release/*"] pull_request: + branches: ["main", "release/*"] schedule: - - cron: "0 19 * * 0" + - cron: "30 3 * * 3" jobs: - CodeQL-Build: - # CodeQL runs on ubuntu-latest and windows-latest - runs-on: ubuntu-latest + analyze: + name: Analyze + # Runner size impacts CodeQL analysis time. To learn more, please see: + # - https://gh.io/recommended-hardware-resources-for-running-codeql + # - https://gh.io/supported-runners-and-hardware-resources + # - https://gh.io/using-larger-runners + # Consider using larger runners for possible analysis time improvements. + runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }} + timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }} + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: ["javascript-typescript"] + # CodeQL supports [ 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift' ] + # Use only 'java-kotlin' to analyze code written in Java, Kotlin or both + # Use only 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both + # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support steps: - name: Checkout repository - uses: actions/checkout@v2 - with: - # We must fetch at least the immediate parents so that if this is - # a pull request then we can checkout the head. - fetch-depth: 2 - - # If this run was triggered by a pull request event, then checkout - # the head of the pull request instead of the merge commit. - - run: git checkout HEAD^2 - if: ${{ github.event_name == 'pull_request' }} + uses: actions/checkout@v3 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v1 - # Override language selection by uncommenting this and choosing your languages - # with: - # languages: go, javascript, csharp, python, cpp, java + 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. + + # For more 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). + # Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild - uses: github/codeql-action/autobuild@v1 + uses: github/codeql-action/autobuild@v2 # ℹī¸ Command-line programs to run using the OS shell. - # 📚 https://git.io/JvXDl + # 📚 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 - # and modify them (or add more) to build your code if your project - # uses a compiled language + # 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: | - # make bootstrap - # make release + # - run: | + # echo "Run, Build Application using script" + # ./location_of_script_within_repo/buildscript.sh - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v1 + uses: github/codeql-action/analyze@v2 + with: + category: "/language:${{matrix.language}}"