diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..367876b5 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,206 @@ +version: 2 +updates: + - package-ecosystem: npm + directory: /api-expressjs-openapi-azuresql-js + schedule: + interval: daily + + - package-ecosystem: npm + directory: /api-expressjs-openapi-azuresql + schedule: + interval: daily + + - package-ecosystem: npm + directory: /api-expressjs-openapi-inmemory + schedule: + interval: daily + + - package-ecosystem: npm + directory: /api-expressjs-vm + schedule: + interval: daily + + - package-ecosystem: docker + directory: /api-function-v4-mongodb-mongo/.devcontainer + schedule: + interval: daily + + - package-ecosystem: npm + directory: /api-function-v4-mongodb-mongo + schedule: + interval: daily + + - package-ecosystem: npm + directory: /api-functions-v3-js + schedule: + interval: daily + + - package-ecosystem: npm + directory: /api-functions-v3-mongoose + schedule: + interval: daily + + - package-ecosystem: docker + directory: /api-functions-v3-upload-file/.devcontainer + schedule: + interval: daily + + - package-ecosystem: npm + directory: /api-functions-v3-upload-file + schedule: + interval: daily + + - package-ecosystem: npm + directory: /api-functions-v3 + schedule: + interval: daily + + - package-ecosystem: npm + directory: /api-functions-v4-azure-resource-management + schedule: + interval: daily + + - package-ecosystem: npm + directory: /api-functions-v4-cosmos-db-no-sql + schedule: + interval: daily + + - package-ecosystem: npm + directory: /api-functions-v4-js + schedule: + interval: daily + + - package-ecosystem: npm + directory: /api-functions-v4-mongoose + schedule: + interval: daily + + - package-ecosystem: npm + directory: /api-functions-v4-triggers + schedule: + interval: daily + + - package-ecosystem: npm + directory: /api-functions-v4-typescript-original + schedule: + interval: daily + + - package-ecosystem: npm + directory: /api-functions-v4-upload-file-by-trigger + schedule: + interval: daily + + - package-ecosystem: docker + directory: /api-functions-v4-upload-file/.devcontainer + schedule: + interval: daily + + - package-ecosystem: npm + directory: /api-functions-v4-upload-file + schedule: + interval: daily + + - package-ecosystem: npm + directory: /api-functions-v4 + schedule: + interval: daily + + - package-ecosystem: npm + directory: /api-inmemory + schedule: + interval: daily + + - package-ecosystem: npm + directory: /api + schedule: + interval: daily + + - package-ecosystem: npm + directory: /app-react-vite-openai-chat + schedule: + interval: daily + + - package-ecosystem: npm + directory: /app-react-vite + schedule: + interval: daily + + - package-ecosystem: npm + directory: /azure-upload-file-to-storage/api + schedule: + interval: daily + + - package-ecosystem: npm + directory: /azure-upload-file-to-storage/app + schedule: + interval: daily + + - package-ecosystem: npm + directory: /cli-openai + schedule: + interval: daily + + - package-ecosystem: npm + directory: /e2e-expressjs-default + schedule: + interval: daily + + - package-ecosystem: npm + directory: /lib-azure-sql + schedule: + interval: daily + + - package-ecosystem: npm + directory: /lib-openai + schedule: + interval: daily + + - package-ecosystem: npm + directory: /lib-storage + schedule: + interval: daily + + - package-ecosystem: npm + directory: /lib-util + schedule: + interval: daily + + - package-ecosystem: npm + directory: /lib + schedule: + interval: daily + + - package-ecosystem: npm + directory: / + schedule: + interval: daily + + - package-ecosystem: npm + directory: /quickstarts/azure-openai-assistants/js + schedule: + interval: daily + + - package-ecosystem: npm + directory: /quickstarts/azure-openai-assistants/ts + schedule: + interval: daily + + - package-ecosystem: npm + directory: /quickstarts/service-bus/ts + schedule: + interval: daily + + - package-ecosystem: npm + directory: /scripts + schedule: + interval: daily + + - package-ecosystem: npm + directory: /sdk-azure-openai + schedule: + interval: daily + + - package-ecosystem: npm + directory: /test-api-functions-v4 + schedule: + interval: daily diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 7b4fde2b..e5ffff22 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -13,81 +13,69 @@ name: "CodeQL" on: push: - branches: [ "main" ] + + branches: ["main"] pull_request: - branches: [ "main" ] + # The branches below must be a subset of the branches above + branches: ["main"] schedule: - - cron: '28 4 * * 3' + - cron: "0 0 * * 1" + +permissions: + contents: read jobs: analyze: - name: Analyze (${{ matrix.language }}) - # 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 (GitHub.com only) - # Consider using larger runners or machines with greater resources for possible analysis time improvements. - runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }} - timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }} + name: Analyze + runs-on: ubuntu-latest permissions: - # required for all workflows - security-events: write - - # required to fetch internal or private CodeQL packs - packages: read - - # only required for workflows in private repositories actions: read contents: read + security-events: write + strategy: fail-fast: false matrix: - include: - - language: javascript-typescript - build-mode: none - # CodeQL supports the following values keywords for 'language': 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift' - # Use `c-cpp` to analyze code written in C, C++ or both - # Use 'java-kotlin' to analyze code written in Java, Kotlin or both - # Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both - # To learn more about changing the languages that are analyzed or customizing the build mode for your analysis, - # see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning. - # If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how - # your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages + + language: ["javascript", "typescript"] + # CodeQL supports [ $supported-codeql-languages ] + # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support + steps: - - name: Checkout repository - uses: actions/checkout@v4 + - name: Harden Runner + uses: step-security/harden-runner@0d381219ddf674d61a7572ddd19d7941e271515c # v2.9.0 + with: + egress-policy: audit + + - name: Checkout repository + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@5cf07d8b700b67e235fbb65cbc84f69c0cf10464 # v3.25.14 + 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. + + # 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@5cf07d8b700b67e235fbb65cbc84f69c0cf10464 # v3.25.14 - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v3 - with: - languages: ${{ matrix.language }} - build-mode: ${{ matrix.build-mode }} - # 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. + # ℹī¸ 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 - # 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 + # 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 analyze step fails for one of the languages you are analyzing with - # "We were unable to automatically build your code", modify the matrix above - # to set the build mode to "manual" for that language. Then modify this step - # to build your code. - # ℹī¸ 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: matrix.build-mode == 'manual' - shell: bash - run: | - echo 'If you are using a "manual" build mode for one or more of the' \ - 'languages you are analyzing, replace this with the commands to build' \ - 'your code, for example:' - echo ' make bootstrap' - echo ' make release' - exit 1 + # - run: | + # echo "Run, Build Application using script" + # ./location_of_script_within_repo/buildscript.sh - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v3 - with: - category: "/language:${{matrix.language}}" + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@5cf07d8b700b67e235fbb65cbc84f69c0cf10464 # v3.25.14 + with: + category: "/language:${{matrix.language}}" diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml new file mode 100644 index 00000000..f072eaba --- /dev/null +++ b/.github/workflows/dependency-review.yml @@ -0,0 +1,27 @@ +# Dependency Review Action +# +# This Action will scan dependency manifest files that change as part of a Pull Request, +# surfacing known-vulnerable versions of the packages declared or updated in the PR. +# Once installed, if the workflow run is marked as required, +# PRs introducing known-vulnerable packages will be blocked from merging. +# +# Source repository: https://github.com/actions/dependency-review-action +name: 'Dependency Review' +on: [pull_request] + +permissions: + contents: read + +jobs: + dependency-review: + runs-on: ubuntu-latest + steps: + - name: Harden Runner + uses: step-security/harden-runner@0d381219ddf674d61a7572ddd19d7941e271515c # v2.9.0 + with: + egress-policy: audit + + - name: 'Checkout Repository' + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + - name: 'Dependency Review' + uses: actions/dependency-review-action@5a2ce3f5b92ee19cbb1541a4984c76d921601d7c # v4.3.4 diff --git a/.github/workflows/scorecards.yml b/.github/workflows/scorecards.yml new file mode 100644 index 00000000..28f3e149 --- /dev/null +++ b/.github/workflows/scorecards.yml @@ -0,0 +1,76 @@ +# This workflow uses actions that are not certified by GitHub. They are provided +# by a third-party and are governed by separate terms of service, privacy +# policy, and support documentation. + +name: Scorecard supply-chain security +on: + # For Branch-Protection check. Only the default branch is supported. See + # https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection + branch_protection_rule: + # To guarantee Maintained check is occasionally updated. See + # https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained + schedule: + - cron: '20 7 * * 2' + push: + branches: ["main"] + +# Declare default permissions as read only. +permissions: read-all + +jobs: + analysis: + name: Scorecard analysis + runs-on: ubuntu-latest + permissions: + # Needed to upload the results to code-scanning dashboard. + security-events: write + # Needed to publish results and get a badge (see publish_results below). + id-token: write + contents: read + actions: read + + steps: + - name: Harden Runner + uses: step-security/harden-runner@0d381219ddf674d61a7572ddd19d7941e271515c # v2.9.0 + with: + egress-policy: audit + + - name: "Checkout code" + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + with: + persist-credentials: false + + - name: "Run analysis" + uses: ossf/scorecard-action@dc50aa9510b46c811795eb24b2f1ba02a914e534 # v2.3.3 + with: + results_file: results.sarif + results_format: sarif + # (Optional) "write" PAT token. Uncomment the `repo_token` line below if: + # - you want to enable the Branch-Protection check on a *public* repository, or + # - you are installing Scorecards on a *private* repository + # To create the PAT, follow the steps in https://github.com/ossf/scorecard-action#authentication-with-pat. + # repo_token: ${{ secrets.SCORECARD_TOKEN }} + + # Public repositories: + # - Publish results to OpenSSF REST API for easy access by consumers + # - Allows the repository to include the Scorecard badge. + # - See https://github.com/ossf/scorecard-action#publishing-results. + # For private repositories: + # - `publish_results` will always be set to `false`, regardless + # of the value entered here. + publish_results: true + + # Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF + # format to the repository Actions tab. + - name: "Upload artifact" + uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4 + with: + name: SARIF file + path: results.sarif + retention-days: 5 + + # Upload the results to GitHub's code scanning dashboard. + - name: "Upload to code-scanning" + uses: github/codeql-action/upload-sarif@5cf07d8b700b67e235fbb65cbc84f69c0cf10464 # v3.25.14 + with: + sarif_file: results.sarif diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 40aeeff0..fda781db 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,4 +2,17 @@ repos: - repo: https://github.com/gitleaks/gitleaks rev: v8.18.2 hooks: - - id: gitleaks \ No newline at end of file + - id: gitleaks + - repo: https://github.com/jumanjihouse/pre-commit-hooks + rev: 3.0.0 + hooks: + - id: shellcheck + - repo: https://github.com/pre-commit/mirrors-eslint + rev: v8.38.0 + hooks: + - id: eslint + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: end-of-file-fixer + - id: trailing-whitespace diff --git a/api-function-v4-mongodb-mongo/.devcontainer/Dockerfile b/api-function-v4-mongodb-mongo/.devcontainer/Dockerfile index 7a800ec4..489327f1 100644 --- a/api-function-v4-mongodb-mongo/.devcontainer/Dockerfile +++ b/api-function-v4-mongodb-mongo/.devcontainer/Dockerfile @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/devcontainers/javascript-node:0-18 +FROM mcr.microsoft.com/devcontainers/javascript-node:0-18@sha256:ed57dd8755b4e75a0426bd10ab1d3a60a22bb21fc2e093801375990978c42fb5 # Install MongoDB command line tools - though mongo-database-tools not available on arm64 ARG MONGO_TOOLS_VERSION=6.0