Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
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
1 change: 1 addition & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ updates:
directory: "/tools/deploy/module3" # Location of package manifests
schedule:
interval: "weekly"
# open-pull-requests-limit: 20
97 changes: 97 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# 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 Advanced"

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
schedule:
- cron: '27 14 * * 5'

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' }}
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

strategy:
fail-fast: false
matrix:
include:
- language: java-kotlin
build-mode: none # This mode only analyzes Java. Set this to 'autobuild' or 'manual' to analyze Kotlin too.
# 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
steps:
- name: Checkout repository
uses: actions/checkout@v4

# 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.

# 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 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

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"

- name: Build Java
run: |
mvn clean package -f tools/deploy/module2/pom.xml

11 changes: 6 additions & 5 deletions .github/workflows/infra-deployment-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:

# Deploy Bicep file
- name: deploy
uses: azure/arm-deploy@v1
uses: azure/arm-deploy@v2
with:
subscriptionId: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
resourceGroupName: ${{ secrets.CLUSTER_RESOURCE_GROUP }}
Expand All @@ -41,13 +41,14 @@ jobs:
failOnStdErr: false

# az feature register for Lab 1
- name: az feature register
run: |
az feature register --namespace "Microsoft.ContainerService" --name "EnableWorkloadIdentityPreview"
# - name: az feature register
# run: |
# az feature register --namespace "Microsoft.ContainerService" --name "EnableWorkloadIdentityPreview"
# az provider register -n Microsoft.ContainerService

# Attach ACR to AKS
- name: attach Azure Container Registry to AKS
run: |
CLUSTER_NAME=$(az aks list --resource-group ${{ secrets.CLUSTER_RESOURCE_GROUP }} --query "[].name" -o tsv)
ACR_NAME=$(az acr list --resource-group ${{ secrets.CLUSTER_RESOURCE_GROUP }} --query "[].name" -o tsv)
az aks update -n $CLUSTER_NAME -g ${{ secrets.CLUSTER_RESOURCE_GROUP }} --attach-acr $ACR_NAME
az aks update -n $CLUSTER_NAME -g ${{ secrets.CLUSTER_RESOURCE_GROUP }} --attach-acr $ACR_NAME
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"snyk.trustedFolders": [
"C:/Users/ngjason/Documents/AKS-DevSecOps-Workshop/AKS_manifest"
],
"snyk.folderConfigs": []
}
17 changes: 17 additions & 0 deletions AKS_manifest/samplepodtest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: v1
kind: Pod
metadata:
name: quick-start
namespace: default
labels:
azure.workload.identity/use: "true"
spec:
serviceAccountName: "workload-identity-sa"
containers:
- image: ghcr.io/azure/azure-workload-identity/msal-net
name: oidc
env:
- name: KEYVAULT_URL
value: "https://akv-gnvotaqtb5nrc.vault.azure.net/"
- name: SECRET_NAME
value: "mysecret"
9 changes: 9 additions & 0 deletions AKS_manifest/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v1
kind: ServiceAccount
metadata:
annotations:
azure.workload.identity/client-id: "d88fd0f6-bed5-4ed8-8d29-aa12a15fc0f6"
labels:
azure.workload.identity/use: "true"
name: "workload-identity-sa"
namespace: "default"
4 changes: 2 additions & 2 deletions tools/deploy/module0/aks.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ param location string = resourceGroup().location
param agentCount int = 3

@description('VM size availability varies by region. If a node contains insufficient compute resources (memory, cpu, etc) pods might fail to run correctly. For more details on restricted VM sizes, see: https://docs.microsoft.com/azure/aks/quotas-skus-regions')
param agentVMSize string = 'Standard_DS2_v2'
param agentVMSize string = 'Standard_D4ds_v5'

// create azure container registry
resource acr 'Microsoft.ContainerRegistry/registries@2023-01-01-preview' = {
Expand All @@ -36,7 +36,7 @@ resource acr 'Microsoft.ContainerRegistry/registries@2023-01-01-preview' = {
}
}

resource aks 'Microsoft.ContainerService/managedClusters@2022-09-02-preview' = {
resource aks 'Microsoft.ContainerService/managedClusters@2024-02-01' = {
name: clusterName
location: location
identity: {
Expand Down
2 changes: 1 addition & 1 deletion tools/deploy/module0/credential.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "gha-oidc",
"issuer": "https://token.actions.githubusercontent.com",
"subject": "repo:<your-github-username>/AKS-DevSecOps-Workshop:ref:refs/heads/main",
"subject": "repo:ng-jianshn/AKS-DevSecOps-Workshop:ref:refs/heads/main",
"audiences": ["api://AzureADTokenExchange"],
"description": "Workload Identity for AKS DevSecOps repo - branch mod 4"
}
4 changes: 2 additions & 2 deletions tools/deploy/module4/deployment-manifest-test-sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ metadata:
spec:
containers:
- name: devsecops-mod4-nginx-app
image: nginx:latest
image: acrgnvotaqtb5nrc.azurecr.io/nginx:latest
ports:
- containerPort: 80
- containerPort: 443
Expand All @@ -15,4 +15,4 @@ spec:
memory: 8Mi
limits:
cpu: 500m
memory: 32Mi
memory: 32Mi
2 changes: 1 addition & 1 deletion tools/deploy/module4/mod4-credential.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "gha-mod4-oidc",
"issuer": "https://token.actions.githubusercontent.com",
"subject": "repo:<your-github-username>/AKS-DevSecOps-Workshop:environment:test",
"subject": "repo:ng-jianshn/AKS-DevSecOps-Workshop:environment:test",
"audiences": ["api://AzureADTokenExchange"],
"description": "Workload Identity for AKS DevSecOps repo - Mod 4"
}
2 changes: 1 addition & 1 deletion tools/deploy/module4/text.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
a
hello jason here