Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[StepSecurity] Apply security best practices #75

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
206 changes: 206 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -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
110 changes: 49 additions & 61 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}}"
27 changes: 27 additions & 0 deletions .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
@@ -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
Loading