Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3ac47adc21 | ||
|
|
8d7f645c0e | ||
|
|
9285f2d842 | ||
|
|
f4e1536d77 | ||
|
|
8d1b353fe2 | ||
|
|
d24b7d131f | ||
|
|
184b7c54e9 | ||
|
|
2471f5adff |
No files matched your search
@@ -19,6 +19,15 @@ release-filters: &release-filters
|
||||
tags:
|
||||
only: /^v[0-9]+\.[0-9]+\.[0-9]+$/
|
||||
|
||||
# Auto-publish filters.
|
||||
develop-filters: &develop-filters
|
||||
branches:
|
||||
only: [develop]
|
||||
|
||||
main-filters: &main-filters
|
||||
branches:
|
||||
only: [main]
|
||||
|
||||
jobs:
|
||||
# Create jobs to test the commands of your orbs.
|
||||
# You may want to add additional validation steps to ensure the commands are working as expected.
|
||||
@@ -29,6 +38,64 @@ jobs:
|
||||
- checkout
|
||||
# Run your orb's commands to validate them.
|
||||
- qqq-orb/install_asciidoctor
|
||||
|
||||
publish-dev-snapshot:
|
||||
docker:
|
||||
- image: circleci/circleci-cli:latest
|
||||
steps:
|
||||
- checkout
|
||||
- run:
|
||||
name: Pack and Publish Dev Snapshot
|
||||
command: |
|
||||
circleci orb pack src > /tmp/orb.yml
|
||||
circleci orb validate /tmp/orb.yml
|
||||
circleci orb publish --token "${CIRCLE_TOKEN}" /tmp/orb.yml kingsrook/qqq-orb@dev:snapshot
|
||||
echo "Published kingsrook/qqq-orb@dev:snapshot"
|
||||
|
||||
publish-production:
|
||||
docker:
|
||||
- image: circleci/circleci-cli:latest
|
||||
steps:
|
||||
- checkout
|
||||
- add_ssh_keys
|
||||
- run:
|
||||
name: Calculate Next Version and Publish
|
||||
command: |
|
||||
git fetch --tags
|
||||
LATEST=$(git tag -l 'v*' | sort -V | tail -1)
|
||||
LATEST=${LATEST:-v0.0.0}
|
||||
LATEST_CLEAN=${LATEST#v}
|
||||
|
||||
# Check recent commit messages for bump keywords
|
||||
BUMP="patch"
|
||||
COMMITS=$(git log "${LATEST}..HEAD" --pretty=%s 2>/dev/null || git log --pretty=%s -10)
|
||||
if echo "${COMMITS}" | grep -qi '\[major\]'; then
|
||||
BUMP="major"
|
||||
elif echo "${COMMITS}" | grep -qi '\[minor\]'; then
|
||||
BUMP="minor"
|
||||
fi
|
||||
|
||||
IFS='.' read -r MAJOR MINOR PATCH \<<< "${LATEST_CLEAN}"
|
||||
case "${BUMP}" in
|
||||
major) MAJOR=$((MAJOR + 1)); MINOR=0; PATCH=0 ;;
|
||||
minor) MINOR=$((MINOR + 1)); PATCH=0 ;;
|
||||
patch) PATCH=$((PATCH + 1)) ;;
|
||||
esac
|
||||
VERSION="${MAJOR}.${MINOR}.${PATCH}"
|
||||
|
||||
echo "Latest: ${LATEST} | Bump: ${BUMP} | Next: ${VERSION}"
|
||||
|
||||
circleci orb pack src > /tmp/orb.yml
|
||||
circleci orb validate /tmp/orb.yml
|
||||
circleci orb publish --token "${CIRCLE_TOKEN}" /tmp/orb.yml "kingsrook/qqq-orb@${VERSION}"
|
||||
|
||||
git config user.email "ci@qrun.io"
|
||||
git config user.name "CircleCI"
|
||||
git tag -a "v${VERSION}" -m "Release v${VERSION}"
|
||||
git push origin "v${VERSION}"
|
||||
|
||||
echo "Published kingsrook/qqq-orb@${VERSION}"
|
||||
|
||||
workflows:
|
||||
test-deploy:
|
||||
jobs:
|
||||
@@ -49,3 +116,13 @@ workflows:
|
||||
- command-test
|
||||
context: orb-publishing
|
||||
filters: *release-filters
|
||||
# Auto-publish dev snapshot on develop
|
||||
- publish-dev-snapshot:
|
||||
context: orb-publishing
|
||||
filters: *develop-filters
|
||||
requires: [command-test]
|
||||
# Auto-publish production release on main
|
||||
- publish-production:
|
||||
context: orb-publishing
|
||||
filters: *main-filters
|
||||
requires: [command-test]
|
||||
@@ -5,6 +5,20 @@ All notable changes to QQQ Orb will be documented in this file.
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Added
|
||||
- Auto-publish `dev:snapshot` on develop branch pushes
|
||||
- Auto-publish production releases on main branch pushes with semantic version bumping
|
||||
- Support for `[major]` and `[minor]` commit keywords to control version bumps (default: patch)
|
||||
- Security scanning job with Gitleaks, Semgrep, OWASP Dependency Check, and CycloneDX SBOM
|
||||
|
||||
## [0.6.2] - 2026-01-30
|
||||
|
||||
### Fixed
|
||||
- Node.js version commit fails with `invalid refspec 'HEAD:'` when `CIRCLE_BRANCH` is empty (detached HEAD builds)
|
||||
- Aligned `node_version_commit.sh` with Maven equivalent: added feature branch skip, empty branch fallback, and non-fatal push handling
|
||||
|
||||
## [0.6.1] - 2026-01-18
|
||||
|
||||
### Fixed
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
CircleCI orb for QQQ framework projects.
|
||||
|
||||
**For:** Teams using CircleCI to build, test, and publish QQQ applications
|
||||
**Status:** Stable (v0.6.1)
|
||||
**Status:** Stable (v0.6.x)
|
||||
|
||||
## Why This Exists
|
||||
|
||||
@@ -58,6 +58,7 @@ workflows:
|
||||
| `node_test_only` | Build and test Node.js projects |
|
||||
| `node_publish` | Build, test, and publish Node.js packages |
|
||||
| `static_analysis` | Run SpotBugs and PMD static analysis |
|
||||
| `security_scan` | Run Gitleaks, Semgrep, OWASP Dependency Check, and CycloneDX SBOM |
|
||||
|
||||
### Branch Types
|
||||
|
||||
@@ -94,16 +95,23 @@ Maven jobs use machine executors with Docker pre-installed. Tests using Testcont
|
||||
| `GPG_PASSPHRASE` | GPG passphrase |
|
||||
| `GITHUB_TOKEN` | GitHub API token |
|
||||
|
||||
## Orb Publishing
|
||||
|
||||
The orb auto-publishes via CircleCI:
|
||||
|
||||
| Branch | Action |
|
||||
|--------|--------|
|
||||
| `develop` | Publishes `kingsrook/qqq-orb@dev:snapshot` |
|
||||
| `main` | Auto-increments version and publishes production release |
|
||||
| `vX.Y.Z` tag | Manual production release (legacy) |
|
||||
|
||||
Version bumps on main default to patch. Include `[minor]` or `[major]` in a commit message to bump accordingly.
|
||||
|
||||
## Project Status
|
||||
|
||||
**Maturity:** Stable, used across all QQQ repositories
|
||||
**Breaking changes:** See [CHANGELOG.md](CHANGELOG.md)
|
||||
|
||||
**Roadmap:**
|
||||
- GitHub Actions support
|
||||
- Parallel test execution
|
||||
- Container image publishing
|
||||
|
||||
## Contributing
|
||||
|
||||
```bash
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
description: >
|
||||
Collects all security scan reports into a central location for artifact
|
||||
storage. Generates a summary.txt with finding counts from each tool.
|
||||
|
||||
steps:
|
||||
- run:
|
||||
name: Collect Security Reports
|
||||
command: <<include(scripts/collect_security_reports.sh)>>
|
||||
when: always
|
||||
@@ -0,0 +1,9 @@
|
||||
description: >
|
||||
Generates a CycloneDX Software Bill of Materials (SBOM) in JSON format.
|
||||
Uses the CycloneDX Maven plugin to produce an aggregate BOM across all
|
||||
modules. No pom.xml changes required -- runs as a CLI Maven goal.
|
||||
|
||||
steps:
|
||||
- run:
|
||||
name: Generate CycloneDX SBOM
|
||||
command: <<include(scripts/run_cyclonedx_sbom.sh)>>
|
||||
@@ -0,0 +1,17 @@
|
||||
description: >
|
||||
Runs Gitleaks secret detection scan on the repository.
|
||||
Detects hardcoded secrets, API keys, passwords, and tokens in source code
|
||||
and git history. Reports findings in JSON format.
|
||||
|
||||
parameters:
|
||||
fail_on_findings:
|
||||
type: boolean
|
||||
default: false
|
||||
description: "Fail the build if Gitleaks detects secrets"
|
||||
|
||||
steps:
|
||||
- run:
|
||||
name: Run Gitleaks Secret Detection
|
||||
environment:
|
||||
GITLEAKS_FAIL_ON_FINDINGS: << parameters.fail_on_findings >>
|
||||
command: <<include(scripts/run_gitleaks.sh)>>
|
||||
@@ -0,0 +1,32 @@
|
||||
description: >
|
||||
Runs OWASP Dependency-Check to scan project dependencies for known CVEs.
|
||||
Uses the dependency-check-maven plugin as a CLI goal (no pom.xml changes needed).
|
||||
Includes retry logic (3 attempts) for NVD database download reliability.
|
||||
Supports NVD API key for faster database updates via NVD_API_KEY env var.
|
||||
|
||||
parameters:
|
||||
fail_on_cvss:
|
||||
type: boolean
|
||||
default: false
|
||||
description: "Fail the build if vulnerabilities exceed the CVSS threshold"
|
||||
cvss_threshold:
|
||||
type: string
|
||||
default: "7"
|
||||
description: "CVSS score threshold (0-10). Vulnerabilities at or above this score are flagged."
|
||||
|
||||
steps:
|
||||
- restore_cache:
|
||||
keys:
|
||||
- v1-owasp-nvd-cache-{{ .Branch }}
|
||||
- v1-owasp-nvd-cache-
|
||||
- run:
|
||||
name: Run OWASP Dependency-Check
|
||||
environment:
|
||||
OWASP_FAIL_ON_CVSS: << parameters.fail_on_cvss >>
|
||||
OWASP_CVSS_THRESHOLD: << parameters.cvss_threshold >>
|
||||
command: <<include(scripts/run_owasp_dependency_check.sh)>>
|
||||
no_output_timeout: 30m
|
||||
- save_cache:
|
||||
paths:
|
||||
- ~/.m2/repository/org/owasp
|
||||
key: v1-owasp-nvd-cache-{{ .Branch }}-{{ epoch }}
|
||||
@@ -0,0 +1,22 @@
|
||||
description: >
|
||||
Runs Semgrep SAST (Static Application Security Testing) analysis.
|
||||
Scans source code for security vulnerabilities, code quality issues,
|
||||
and OWASP Top 10 patterns. Produces JSON and SARIF reports.
|
||||
|
||||
parameters:
|
||||
fail_on_findings:
|
||||
type: boolean
|
||||
default: false
|
||||
description: "Fail the build if Semgrep finds security issues"
|
||||
rulesets:
|
||||
type: string
|
||||
default: "p/java p/owasp-top-ten p/security-audit"
|
||||
description: "Space-separated list of Semgrep rulesets to run"
|
||||
|
||||
steps:
|
||||
- run:
|
||||
name: Run Semgrep SAST Analysis
|
||||
environment:
|
||||
SEMGREP_FAIL_ON_FINDINGS: << parameters.fail_on_findings >>
|
||||
SEMGREP_RULESETS: << parameters.rulesets >>
|
||||
command: <<include(scripts/run_semgrep.sh)>>
|
||||
+10
-1
@@ -1,6 +1,7 @@
|
||||
description: >
|
||||
Complete CI/CD workflow example for Maven-based projects using GitFlow branching strategy.
|
||||
This example demonstrates how to use the qqq-orb for automated building, testing, and releasing.
|
||||
This example demonstrates how to use the qqq-orb for automated building, testing, releasing,
|
||||
and security scanning.
|
||||
|
||||
usage:
|
||||
version: 2.1
|
||||
@@ -72,3 +73,11 @@ usage:
|
||||
branches:
|
||||
only:
|
||||
- /hotfix\/.*/
|
||||
|
||||
security_scan:
|
||||
jobs:
|
||||
- qqq-orb/security_scan:
|
||||
context: [ qqq-maven-registry-credentials, qqq-security-credentials ]
|
||||
filters:
|
||||
branches:
|
||||
only: [ develop ]
|
||||
@@ -0,0 +1,101 @@
|
||||
description: >
|
||||
Runs security scanning tools on a Maven project: Gitleaks (secret detection),
|
||||
Semgrep (SAST), OWASP Dependency-Check (CVE scanning), and CycloneDX (SBOM).
|
||||
All tools default to report-only mode. Use fail_on_* parameters to enforce gates.
|
||||
|
||||
Usage in consuming repo:
|
||||
workflows:
|
||||
security_scan:
|
||||
jobs:
|
||||
- qqq-orb/security_scan:
|
||||
context: [qqq-maven-registry-credentials, qqq-security-credentials]
|
||||
filters:
|
||||
branches:
|
||||
only: [develop]
|
||||
|
||||
executor: java
|
||||
|
||||
parameters:
|
||||
java_version:
|
||||
type: string
|
||||
default: "21"
|
||||
description: "Java major version to install"
|
||||
run_gitleaks:
|
||||
type: boolean
|
||||
default: true
|
||||
description: "Run Gitleaks secret detection"
|
||||
run_semgrep:
|
||||
type: boolean
|
||||
default: true
|
||||
description: "Run Semgrep SAST analysis"
|
||||
run_owasp:
|
||||
type: boolean
|
||||
default: true
|
||||
description: "Run OWASP Dependency-Check CVE scanning"
|
||||
run_sbom:
|
||||
type: boolean
|
||||
default: true
|
||||
description: "Run CycloneDX SBOM generation"
|
||||
fail_on_gitleaks:
|
||||
type: boolean
|
||||
default: false
|
||||
description: "Fail the build if Gitleaks finds secrets"
|
||||
fail_on_semgrep:
|
||||
type: boolean
|
||||
default: false
|
||||
description: "Fail the build if Semgrep finds security issues"
|
||||
fail_on_owasp:
|
||||
type: boolean
|
||||
default: false
|
||||
description: "Fail the build if OWASP finds CVEs above threshold"
|
||||
semgrep_rulesets:
|
||||
type: string
|
||||
default: "p/java p/owasp-top-ten p/security-audit"
|
||||
description: "Space-separated list of Semgrep rulesets"
|
||||
owasp_cvss_threshold:
|
||||
type: string
|
||||
default: "7"
|
||||
description: "CVSS score threshold for OWASP (0-10)"
|
||||
|
||||
steps:
|
||||
- install_java:
|
||||
java_version: << parameters.java_version >>
|
||||
- git_full_checkout
|
||||
- run:
|
||||
name: Setup Maven Settings
|
||||
command: <<include(scripts/setup_maven_settings.sh)>>
|
||||
- restore_cache:
|
||||
keys:
|
||||
- v1-dependencies-{{ checksum "pom.xml" }}
|
||||
- run:
|
||||
name: Build and Install for Security Analysis
|
||||
command: <<include(scripts/mvn_install_for_analysis.sh)>>
|
||||
- save_cache:
|
||||
paths:
|
||||
- ~/.m2
|
||||
key: v1-dependencies-{{ checksum "pom.xml" }}
|
||||
- when:
|
||||
condition: << parameters.run_gitleaks >>
|
||||
steps:
|
||||
- run_gitleaks:
|
||||
fail_on_findings: << parameters.fail_on_gitleaks >>
|
||||
- when:
|
||||
condition: << parameters.run_semgrep >>
|
||||
steps:
|
||||
- run_semgrep:
|
||||
fail_on_findings: << parameters.fail_on_semgrep >>
|
||||
rulesets: << parameters.semgrep_rulesets >>
|
||||
- when:
|
||||
condition: << parameters.run_owasp >>
|
||||
steps:
|
||||
- run_owasp_dependency_check:
|
||||
fail_on_cvss: << parameters.fail_on_owasp >>
|
||||
cvss_threshold: << parameters.owasp_cvss_threshold >>
|
||||
- when:
|
||||
condition: << parameters.run_sbom >>
|
||||
steps:
|
||||
- run_cyclonedx_sbom
|
||||
- collect_security_reports
|
||||
- store_artifacts:
|
||||
path: /home/circleci/security-reports
|
||||
destination: security-reports
|
||||
@@ -0,0 +1,88 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Collect security scan reports to a central location for artifacts
|
||||
REPORT_DIR="/home/circleci/security-reports"
|
||||
mkdir -p "$REPORT_DIR/gitleaks" "$REPORT_DIR/semgrep" "$REPORT_DIR/owasp" "$REPORT_DIR/sbom"
|
||||
|
||||
echo "Collecting security scan reports..."
|
||||
|
||||
# Collect Gitleaks reports
|
||||
if [ -f /tmp/gitleaks-report.json ]; then
|
||||
cp /tmp/gitleaks-report.json "$REPORT_DIR/gitleaks/" 2>/dev/null || true
|
||||
fi
|
||||
|
||||
# Collect Semgrep reports
|
||||
if [ -f /tmp/semgrep-report.json ]; then
|
||||
cp /tmp/semgrep-report.json "$REPORT_DIR/semgrep/" 2>/dev/null || true
|
||||
fi
|
||||
if [ -f /tmp/semgrep-report.sarif ]; then
|
||||
cp /tmp/semgrep-report.sarif "$REPORT_DIR/semgrep/" 2>/dev/null || true
|
||||
fi
|
||||
|
||||
# Collect OWASP Dependency-Check reports
|
||||
if [ -f /tmp/owasp-dependency-check.json ]; then
|
||||
cp /tmp/owasp-dependency-check.json "$REPORT_DIR/owasp/" 2>/dev/null || true
|
||||
fi
|
||||
if [ -f /tmp/owasp-dependency-check.html ]; then
|
||||
cp /tmp/owasp-dependency-check.html "$REPORT_DIR/owasp/" 2>/dev/null || true
|
||||
fi
|
||||
|
||||
# Collect CycloneDX SBOM
|
||||
if [ -f /tmp/cyclonedx-sbom.json ]; then
|
||||
cp /tmp/cyclonedx-sbom.json "$REPORT_DIR/sbom/" 2>/dev/null || true
|
||||
fi
|
||||
|
||||
# Generate combined summary
|
||||
{
|
||||
echo "=== Security Scan Report Summary ==="
|
||||
echo "Generated: $(date)"
|
||||
echo ""
|
||||
|
||||
echo "Gitleaks (Secret Detection):"
|
||||
if [ -f "$REPORT_DIR/gitleaks/gitleaks-report.json" ]; then
|
||||
COUNT=$(python3 -c "import json; print(len(json.load(open('$REPORT_DIR/gitleaks/gitleaks-report.json'))))" 2>/dev/null || echo "unknown")
|
||||
echo " Findings: ${COUNT}"
|
||||
else
|
||||
echo " Not run or no report"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "Semgrep (SAST):"
|
||||
if [ -f "$REPORT_DIR/semgrep/semgrep-report.json" ]; then
|
||||
COUNT=$(python3 -c "import json; r=json.load(open('$REPORT_DIR/semgrep/semgrep-report.json')); print(len(r.get('results', [])))" 2>/dev/null || echo "unknown")
|
||||
echo " Findings: ${COUNT}"
|
||||
else
|
||||
echo " Not run or no report"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "OWASP Dependency-Check (CVEs):"
|
||||
if [ -f "$REPORT_DIR/owasp/owasp-dependency-check.json" ]; then
|
||||
COUNT=$(python3 -c "
|
||||
import json
|
||||
r = json.load(open('$REPORT_DIR/owasp/owasp-dependency-check.json'))
|
||||
deps = r.get('dependencies', [])
|
||||
vulns = sum(len(d.get('vulnerabilities', [])) for d in deps)
|
||||
print(vulns)
|
||||
" 2>/dev/null || echo "unknown")
|
||||
echo " Vulnerabilities: ${COUNT}"
|
||||
else
|
||||
echo " Not run or no report"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "CycloneDX SBOM:"
|
||||
if [ -f "$REPORT_DIR/sbom/cyclonedx-sbom.json" ]; then
|
||||
COUNT=$(python3 -c "import json; r=json.load(open('$REPORT_DIR/sbom/cyclonedx-sbom.json')); print(len(r.get('components', [])))" 2>/dev/null || echo "unknown")
|
||||
echo " Components: ${COUNT}"
|
||||
else
|
||||
echo " Not run or no report"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "==================================="
|
||||
} > "$REPORT_DIR/summary.txt"
|
||||
|
||||
cat "$REPORT_DIR/summary.txt"
|
||||
echo ""
|
||||
echo "Reports collected to: $REPORT_DIR"
|
||||
@@ -0,0 +1,38 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
echo "Generating CycloneDX SBOM..."
|
||||
|
||||
##################################
|
||||
## Run CycloneDX Maven plugin ##
|
||||
##################################
|
||||
mvn -s /tmp/circleci/mvn-settings.xml \
|
||||
--no-transfer-progress \
|
||||
org.cyclonedx:cyclonedx-maven-plugin:2.9.1:makeAggregateBom \
|
||||
-DskipTests \
|
||||
-DoutputFormat=json \
|
||||
-DoutputName=bom
|
||||
|
||||
##################################
|
||||
## Collect SBOM output ##
|
||||
##################################
|
||||
echo ""
|
||||
echo "=== CycloneDX SBOM Summary ==="
|
||||
if [ -f target/bom.json ]; then
|
||||
COMPONENTS=$(python3 -c "import json; r=json.load(open('target/bom.json')); print(len(r.get('components', [])))" 2>/dev/null || echo "unknown")
|
||||
echo " Components: ${COMPONENTS}"
|
||||
cp target/bom.json /tmp/cyclonedx-sbom.json
|
||||
else
|
||||
# Multi-module projects may output to different location
|
||||
BOM_FILE=$(find . -name "bom.json" -path "*/target/*" | head -1)
|
||||
if [ -n "${BOM_FILE}" ]; then
|
||||
COMPONENTS=$(python3 -c "import json; r=json.load(open('${BOM_FILE}')); print(len(r.get('components', [])))" 2>/dev/null || echo "unknown")
|
||||
echo " Components: ${COMPONENTS}"
|
||||
cp "${BOM_FILE}" /tmp/cyclonedx-sbom.json
|
||||
else
|
||||
echo " No SBOM generated"
|
||||
fi
|
||||
fi
|
||||
echo "==============================="
|
||||
|
||||
echo "CycloneDX SBOM generation complete"
|
||||
@@ -0,0 +1,46 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
echo "Running Gitleaks secret detection..."
|
||||
|
||||
##################################
|
||||
## Install Gitleaks binary ##
|
||||
##################################
|
||||
GITLEAKS_VERSION="8.21.2"
|
||||
curl -sSfL "https://github.com/gitleaks/gitleaks/releases/download/v${GITLEAKS_VERSION}/gitleaks_${GITLEAKS_VERSION}_linux_x64.tar.gz" \
|
||||
| tar -xz -C /tmp
|
||||
chmod +x /tmp/gitleaks
|
||||
|
||||
##################################
|
||||
## Run Gitleaks scan ##
|
||||
##################################
|
||||
EXIT_CODE=0
|
||||
/tmp/gitleaks detect \
|
||||
--source=. \
|
||||
--report-format=json \
|
||||
--report-path=/tmp/gitleaks-report.json \
|
||||
--verbose \
|
||||
|| EXIT_CODE=$?
|
||||
|
||||
##################################
|
||||
## Summarize results ##
|
||||
##################################
|
||||
echo ""
|
||||
echo "=== Gitleaks Summary ==="
|
||||
if [ -f /tmp/gitleaks-report.json ]; then
|
||||
COUNT=$(python3 -c "import json; print(len(json.load(open('/tmp/gitleaks-report.json'))))" 2>/dev/null || echo "unknown")
|
||||
echo " Findings: ${COUNT}"
|
||||
else
|
||||
echo " Findings: 0"
|
||||
fi
|
||||
echo "========================="
|
||||
|
||||
##################################
|
||||
## Handle fail_on flag ##
|
||||
##################################
|
||||
if [ "${GITLEAKS_FAIL_ON_FINDINGS}" = "true" ] && [ "${EXIT_CODE}" -ne 0 ]; then
|
||||
echo "Gitleaks found secrets and fail_on_gitleaks is enabled. Failing build."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Gitleaks scan complete (exit code: ${EXIT_CODE})"
|
||||
@@ -0,0 +1,98 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
echo "Running OWASP Dependency-Check..."
|
||||
|
||||
##################################
|
||||
## Build Maven command ##
|
||||
##################################
|
||||
MVN_CMD="mvn -s /tmp/circleci/mvn-settings.xml --no-transfer-progress"
|
||||
MVN_CMD="${MVN_CMD} org.owasp:dependency-check-maven:12.1.0:aggregate"
|
||||
MVN_CMD="${MVN_CMD} -DskipTests"
|
||||
MVN_CMD="${MVN_CMD} -DfailBuildOnCVSS=${OWASP_CVSS_THRESHOLD}"
|
||||
MVN_CMD="${MVN_CMD} -Dformats=JSON,HTML"
|
||||
|
||||
# Use NVD API key if available (speeds up NVD database updates)
|
||||
if [ -n "${NVD_API_KEY}" ]; then
|
||||
MVN_CMD="${MVN_CMD} -DnvdApiKey=${NVD_API_KEY}"
|
||||
echo " NVD API key detected -- using authenticated NVD access"
|
||||
else
|
||||
echo " No NVD API key -- using unauthenticated access (slower)"
|
||||
fi
|
||||
|
||||
##################################
|
||||
## Run with retry logic (3x) ##
|
||||
##################################
|
||||
MAX_RETRIES=3
|
||||
ATTEMPT=1
|
||||
EXIT_CODE=0
|
||||
|
||||
while [ "${ATTEMPT}" -le "${MAX_RETRIES}" ]; do
|
||||
echo ""
|
||||
echo "OWASP Dependency-Check attempt ${ATTEMPT}/${MAX_RETRIES}..."
|
||||
|
||||
EXIT_CODE=0
|
||||
eval "${MVN_CMD}" 2>&1 | tee /tmp/owasp-output.txt || EXIT_CODE=$?
|
||||
|
||||
# Exit code 1 = vulnerabilities found (expected), anything else = tool error
|
||||
if [ "${EXIT_CODE}" -eq 0 ] || [ "${EXIT_CODE}" -eq 1 ]; then
|
||||
break
|
||||
fi
|
||||
|
||||
echo "Attempt ${ATTEMPT} failed with exit code ${EXIT_CODE}"
|
||||
ATTEMPT=$((ATTEMPT + 1))
|
||||
|
||||
if [ "${ATTEMPT}" -le "${MAX_RETRIES}" ]; then
|
||||
echo "Retrying in 30 seconds..."
|
||||
sleep 30
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "${ATTEMPT}" -gt "${MAX_RETRIES}" ] && [ "${EXIT_CODE}" -gt 1 ]; then
|
||||
echo "OWASP Dependency-Check failed after ${MAX_RETRIES} attempts"
|
||||
echo "This is typically caused by NVD database download issues"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
##################################
|
||||
## Collect reports ##
|
||||
##################################
|
||||
REPORT_FILE=$(find . -name "dependency-check-report.json" -path "*/target/*" | head -1)
|
||||
if [ -n "${REPORT_FILE}" ]; then
|
||||
cp "${REPORT_FILE}" /tmp/owasp-dependency-check.json
|
||||
fi
|
||||
|
||||
HTML_REPORT=$(find . -name "dependency-check-report.html" -path "*/target/*" | head -1)
|
||||
if [ -n "${HTML_REPORT}" ]; then
|
||||
cp "${HTML_REPORT}" /tmp/owasp-dependency-check.html
|
||||
fi
|
||||
|
||||
##################################
|
||||
## Summarize results ##
|
||||
##################################
|
||||
echo ""
|
||||
echo "=== OWASP Dependency-Check Summary ==="
|
||||
if [ -f /tmp/owasp-dependency-check.json ]; then
|
||||
VULN_COUNT=$(python3 -c "
|
||||
import json
|
||||
r = json.load(open('/tmp/owasp-dependency-check.json'))
|
||||
deps = r.get('dependencies', [])
|
||||
vulns = sum(len(d.get('vulnerabilities', [])) for d in deps)
|
||||
print(vulns)
|
||||
" 2>/dev/null || echo "unknown")
|
||||
echo " Vulnerabilities: ${VULN_COUNT}"
|
||||
echo " CVSS Threshold: ${OWASP_CVSS_THRESHOLD}"
|
||||
else
|
||||
echo " No report generated"
|
||||
fi
|
||||
echo "======================================="
|
||||
|
||||
##################################
|
||||
## Handle fail_on flag ##
|
||||
##################################
|
||||
if [ "${OWASP_FAIL_ON_CVSS}" = "true" ] && [ "${EXIT_CODE}" -ne 0 ]; then
|
||||
echo "OWASP found CVEs above threshold and fail_on_owasp is enabled. Failing build."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "OWASP Dependency-Check complete"
|
||||
@@ -0,0 +1,44 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
echo "Running Semgrep SAST analysis..."
|
||||
|
||||
##################################
|
||||
## Install Semgrep ##
|
||||
##################################
|
||||
pip3 install --quiet semgrep
|
||||
|
||||
##################################
|
||||
## Run Semgrep scan ##
|
||||
##################################
|
||||
EXIT_CODE=0
|
||||
semgrep scan \
|
||||
--config "${SEMGREP_RULESETS// / --config }" \
|
||||
--json --output /tmp/semgrep-report.json \
|
||||
--sarif --sarif-output /tmp/semgrep-report.sarif \
|
||||
--metrics=off \
|
||||
. \
|
||||
|| EXIT_CODE=$?
|
||||
|
||||
##################################
|
||||
## Summarize results ##
|
||||
##################################
|
||||
echo ""
|
||||
echo "=== Semgrep Summary ==="
|
||||
if [ -f /tmp/semgrep-report.json ]; then
|
||||
COUNT=$(python3 -c "import json; r=json.load(open('/tmp/semgrep-report.json')); print(len(r.get('results', [])))" 2>/dev/null || echo "unknown")
|
||||
echo " Findings: ${COUNT}"
|
||||
else
|
||||
echo " Findings: 0"
|
||||
fi
|
||||
echo "========================"
|
||||
|
||||
##################################
|
||||
## Handle fail_on flag ##
|
||||
##################################
|
||||
if [ "${SEMGREP_FAIL_ON_FINDINGS}" = "true" ] && [ "${EXIT_CODE}" -ne 0 ]; then
|
||||
echo "Semgrep found issues and fail_on_semgrep is enabled. Failing build."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Semgrep scan complete (exit code: ${EXIT_CODE})"
|
||||
Reference in new issue
Block a user