Skip to content

Commit

Permalink
Add Checkov action to CI/CD pipeline (#1087)
Browse files Browse the repository at this point in the history
* add checkov workflow

* suppress false positive

* supress check

* suppress inputs

* supress manual inputs

* set permissions to read all

* set read all

* add checkov to pipeline

* fixed security on run update opa

* start workflow

* finish workflow

* try different analyzer

* fix lint

* add wrong verb in PS for test

* lint ps w windows

* set path

* no output

* show results

* fix shell

* just commandline

* set warning

* changed default shell

* use profile

* fix singular nouns

* full on pipeline

* remove security push

* Remove comments and unused ML config
  • Loading branch information
james-garriss authored May 20, 2024
1 parent 943c003 commit 034d883
Show file tree
Hide file tree
Showing 17 changed files with 18,780 additions and 22,006 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/build_sign_release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ name: Build and Draft Release
on:
workflow_dispatch:
inputs:
# checkov:skip=CKV_GHA_7:Manual inputs are desired.
releaseName:
description: "Release Name"
required: true
Expand All @@ -19,6 +20,8 @@ on:
type: boolean
default: true

permissions: read-all

jobs:
build-and-draft:
name: Build and Draft Release
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/check_security.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Purpose: Run a static analysis code checker against the repo.

name: Check Security

# This is a reusable workflow called by the pipeline.
on:
workflow_call:
workflow_dispatch:

permissions: read-all

jobs:
check-security:
name: MegaLint Checkov
runs-on: ubuntu-latest
# This condition prevents duplicate runs.
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
defaults:
run:
shell: bash
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Setup Config File
run: cp Testing/Linting/MegaLinter/.mega-linter-security.yml .mega-linter.yml
- name: Check Security
uses: oxsecurity/megalinter/flavors/security@latest
14 changes: 8 additions & 6 deletions .github/workflows/lint_powershell.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,23 @@ on:
workflow_call:
workflow_dispatch:

permissions: read-all

jobs:
powershell-lint-check:
name: MegaLint PowerShell Check
runs-on: ubuntu-latest
# runs-on: ubuntu-latest
runs-on: windows-latest
# This condition prevents duplicate runs.
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
defaults:
run:
shell: bash
shell: pwsh
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Setup Config File
run: cp Testing/Linting/MegaLinter/.mega-linter-powershell.yml .mega-linter.yml
- name: Setup PSScriptAnalyzer settings
run: cp Testing/Linting/MegaLinter/.powershell-psscriptanalyzer.psd1 .powershell-psscriptanalyzer.psd1
- name: Lint PowerShell
uses: oxsecurity/megalinter/flavors/dotnet@latest
- name: Run PSScriptAnalyzer on PowerShell Scripts
run: |
Invoke-ScriptAnalyzer -Path ./ -Recurse -Severity Warning -EnableExit -Profile .powershell-psscriptanalyzer.psd1
2 changes: 2 additions & 0 deletions .github/workflows/lint_yaml.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ on:
workflow_call:
workflow_dispatch:

permissions: read-all

jobs:
yaml-lint-check:
name: MegaLint YAML Check
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/publish_private_package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ on:
# - ".github/workflows/publish_private_package.yaml"
# - "utils/DeployUtils.ps1"

permissions: read-all

env:
GalleryName: PrivateScubaGearGallery

Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/publish_public_package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ name: Publish Public Package
on:
workflow_dispatch:
inputs:
# checkov:skip=CKV_GHA_7:Manual inputs are desired.
OverrideModuleVersion:
description: "Override the version of the release. Restricted to SemVer 1.0 - 3 segments"
required: false
Expand All @@ -24,6 +25,8 @@ on:
# - ".github/workflows/publish_public_package.yaml"
# - "utils/DeployUtils.ps1"

permissions: read-all

jobs:
publish:
name: Publish to PSGallery
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/run_module_version_bump.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ name: Module Version Bump
on:
workflow_dispatch:
inputs:
# checkov:skip=CKV_GHA_7:Manual inputs are desired.
newVersionNumber:
description: "New Version number (e.g., 1.2.4)"
required: true
type: string

permissions: read-all

jobs:
module-version-bump:
runs-on: windows-latest
Expand Down
30 changes: 26 additions & 4 deletions .github/workflows/run_pipeline.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Purpose: Run the CI/CD pipeline that tests, packages, and publishes ScubaGear.
# Note: This pipeline is a work in progress. At the moment, it is only doing linting, syntax checking, and unit testing.
# Note: This pipeline is a work in progress. At the moment, it is only doing linting, syntax checking, security scanning, and unit testing.

name: Run the CI/CD Pipeline

Expand All @@ -8,22 +8,44 @@ on:
pull_request:
workflow_dispatch:

permissions: read-all

jobs:
# Lint and Syntax Checks
lint-yaml:
name: Lint
uses: ./.github/workflows/lint_yaml.yaml
lint-powershell:
name: Lint
uses: ./.github/workflows/lint_powershell.yaml
syntax-markdown:
name: Syntax
uses: ./.github/workflows/syntax_check_markdown.yaml
# Security Checks
scan-secret:
name: Security
needs:
- lint-yaml
- lint-powershell
- syntax-markdown
uses: ./.github/workflows/run_secret_scan.yaml
syntax:
name: Syntax
uses: ./.github/workflows/syntax_check_markdown.yaml
check-security:
name: Security
needs:
- lint-yaml
- lint-powershell
- syntax-markdown
uses: ./.github/workflows/check_security.yaml
# Unit Tests
unit-powershell:
name: Unit
needs:
- scan-secret
- check-security
uses: ./.github/workflows/unit_test_powershell.yaml
unit-opa:
name: Unit
needs:
- scan-secret
- check-security
uses: ./.github/workflows/unit_test_opa.yaml
2 changes: 2 additions & 0 deletions .github/workflows/run_secret_scan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ on:
workflow_call:
workflow_dispatch:

permissions: read-all

jobs:
secret-scan:
name: MegaLint Gitleaks
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/run_smoke_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ on:
- "main"
- "*smoke*"

permissions: read-all

jobs:
smoke-tests:
name: Smoke Tests
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/run_update_opa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ on:
- cron: "11 2 * * 1-5"
workflow_dispatch:

permissions: read-all

jobs:
update-opa-dependency:
runs-on: windows-latest
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/syntax_check_markdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ on:
workflow_call:
workflow_dispatch:

permissions: read-all

jobs:
markdown-check:
name: Markdown Syntax Checks
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/test_production_function.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ on:
- cron: "15 4 * * 0-4"
workflow_dispatch:

permissions: read-all

jobs:
# Build a matrix of aliases for testing.
build-matrix:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/unit_test_opa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ on:
workflow_call:
workflow_dispatch:

permissions: read-all

env:
MODULE_ROOT: PowerShell/ScubaGear

jobs:
opa-tests:
name: OPA Unit Tests
Expand Down
Loading

0 comments on commit 034d883

Please sign in to comment.