Skip to content
Open
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
123 changes: 123 additions & 0 deletions .github/workflows/security-and-quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
name: Security and Code Quality Checks

on:
push:
branches: [ main, develop, 'feature/*' ]
pull_request:
branches: [ main, develop ]

jobs:
terraform-checks:
name: Terraform Checks
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: ~1.0

- name: Terraform Format Check
run: terraform fmt -check -recursive

- name: Terraform Init
run: terraform init -backend=false

- name: Terraform Validate
run: terraform validate

security-scan:
name: Security Scanning
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Run Checkov Security Scan
id: checkov
uses: bridgecrewio/checkov-action@master
with:
directory: .
framework: terraform
output_format: sarif
output_file_path: reports/results.sarif
download_external_modules: true
quiet: true
soft_fail: true

- name: Upload Checkov results to GitHub Security
uses: github/codeql-action/upload-sarif@v3
if: always()
with:
sarif_file: reports/results.sarif

code-quality:
name: Code Quality Checks
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup TFLint
uses: terraform-linters/setup-tflint@v4
with:
tflint_version: latest

- name: Initialize TFLint
run: tflint --init

- name: Run TFLint
run: tflint --format compact

- name: Setup Node.js for Lambda code analysis
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install Lambda dependencies
run: |
cd files/deployable
npm install

- name: Run ESLint on Lambda code
run: |
cd files/deployable
npx eslint . --ext .js --format json --output-file ../../eslint-report.json || true

- name: Upload ESLint results
uses: actions/upload-artifact@v4
if: always()
with:
name: eslint-report
path: eslint-report.json

dependency-check:
name: Dependency Security Check
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install dependencies
run: |
cd files/deployable
npm install

- name: Run npm audit
run: |
cd files/deployable
npm audit --audit-level high
continue-on-error: true
62 changes: 60 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,75 @@
--hook-config=--path-to-file=README.md

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- id: check-case-conflict
- id: check-merge-conflict
- id: check-json
- id: pretty-format-json
args: ['--autofix']
- id: mixed-line-ending

- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.76.0
rev: v1.88.4
hooks:
- id: terraform_fmt
args:
- --args=-recursive

- id: terraform_validate
args:
- --args=-json
- --hook-config=--retry-once-with-cleanup=true

- id: terraform_docs
files: '^.*.tf$'
args:
- *common_tf_docs_readme_file
- *common_tf_docs_config
- --hook-config=--config=data-io/modules/data-io-regional/.terraform-docs.yml
- --hook-config=--config=.terraform-docs.yml

- id: terraform_tflint
args:
- --args=--config=__GIT_WORKING_DIR__/.tflint.hcl

- id: terraform_checkov
args:
- --args=--quiet
- --args=--framework=terraform

- id: terraform_tfsec
args:
- --args=--format=compact

- repo: https://github.com/Yelp/detect-secrets
rev: v1.4.0
hooks:
- id: detect-secrets
args: ['--baseline', '.secrets.baseline']

- repo: https://github.com/pre-commit/mirrors-eslint
rev: v8.57.0
hooks:
- id: eslint
files: 'files/deployable/.*\.(js|ts)$'
additional_dependencies:
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]

- repo: local
hooks:
- id: npm-audit
name: npm audit
entry: bash -c 'cd files/deployable && npm audit --audit-level high'
language: system
files: 'files/deployable/package.*\.json$'
pass_filenames: false
115 changes: 115 additions & 0 deletions .secrets.baseline
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
{
"version": "1.4.0",
"plugins_used": [
{
"name": "ArtifactoryDetector"
},
{
"name": "AWSKeyDetector"
},
{
"name": "AzureStorageKeyDetector"
},
{
"name": "Base64HighEntropyString",
"limit": 4.5
},
{
"name": "BasicAuthDetector"
},
{
"name": "CloudantDetector"
},
{
"name": "DiscordBotTokenDetector"
},
{
"name": "GitHubTokenDetector"
},
{
"name": "HexHighEntropyString",
"limit": 3.0
},
{
"name": "IbmCloudIamDetector"
},
{
"name": "IbmCosHmacDetector"
},
{
"name": "JwtTokenDetector"
},
{
"name": "KeywordDetector",
"keyword_exclude": ""
},
{
"name": "MailchimpDetector"
},
{
"name": "NpmDetector"
},
{
"name": "PrivateKeyDetector"
},
{
"name": "SendGridDetector"
},
{
"name": "SlackDetector"
},
{
"name": "SoftlayerDetector"
},
{
"name": "SquareOAuthDetector"
},
{
"name": "StripeDetector"
},
{
"name": "TwilioKeyDetector"
}
],
"filters_used": [
{
"path": "detect_secrets.filters.allowlist.is_line_allowlisted"
},
{
"path": "detect_secrets.filters.common.is_baseline_file"
},
{
"path": "detect_secrets.filters.common.is_ignored_due_to_verification_policies",
"min_level": 2
},
{
"path": "detect_secrets.filters.heuristic.is_indirect_reference"
},
{
"path": "detect_secrets.filters.heuristic.is_likely_id_string"
},
{
"path": "detect_secrets.filters.heuristic.is_lock_file"
},
{
"path": "detect_secrets.filters.heuristic.is_not_alphanumeric_string"
},
{
"path": "detect_secrets.filters.heuristic.is_potential_uuid"
},
{
"path": "detect_secrets.filters.heuristic.is_prefixed_with_dollar_sign"
},
{
"path": "detect_secrets.filters.heuristic.is_sequential_string"
},
{
"path": "detect_secrets.filters.heuristic.is_swagger_file"
},
{
"path": "detect_secrets.filters.heuristic.is_templated_secret"
}
],
"results": {},
"generated_at": "2024-10-04T08:39:19Z"
}
Loading