Comprehensive guide to devsecops onboarding covering architecture, implementation, testing, and operational patterns for production engineering teams.
DevSecOps onboarding integrates new engineers into the security-conscious software delivery lifecycle, ensuring they can contribute securely from day one. It matters most when a team adopts DevSecOps practices—automated security testing, policy enforcement, and security ownership across development, operations, and security teams—and must scale without introducing security debt.
New engineers must have a consistent, secure, and immediately productive local environment. The onboarding process begins with a script that installs base tooling, configures version control, and sets up the initial project context.
The script setup-dev-environment.sh runs on macOS and Linux and installs git, docker, kubectl, jq, and golang. It then configures Git with user identity, SSH key, and a pre-commit hook using pre-commit framework.
#!/bin/bash
set -euo pipefail
# Install base tools via package manager
if command -v apt &>/dev/null; then
apt update && apt install -y git docker.io kubectl jq golang
elif command -v brew &>/dev/null; then
brew install git docker kubectl jq go
fi
# Configure git
git config --global user.name "Jane Doe"
git config --global user.email "[email protected]"
git config --global init.defaultBranch main
# Generate SSH key
ssh-keygen -t ed25519 -C "[email protected]" -f ~/.ssh/id_ed25519 -N "" -q
# Install pre-commit hooks
pip install pre-commit
cat > .pre-commit-config.yaml << 'EOF'
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: detect-private-key
EOF
git config --local core.hooksPath .git/hooks
pre-commit install --install-hooks
# Ensure Docker is running and accessible
systemctl enable docker
systemctl start docker
The script fails silently if git config --global does not apply the user identity correctly. The most common error is git config --global missing the --global flag, causing configuration to be project-local only. The pre-commit install command must be run *after* the .pre-commit-config.yaml file is written; otherwise, the hooks are not installed.
The onboarding process includes a project-specific setup step. Engineers check out a repository and run make init to bootstrap their environment. This command performs several actions: fetches dependencies, sets up a local database, configures environment variables, and applies security policies.
# Makefile
init: install-deps setup-db setup-env apply-security-policies
install-deps:
@echo "Installing dependencies..."
pip install -r requirements.txt
go mod download
setup-db:
@echo "Setting up database..."
docker-compose up -d db
psql -h localhost -U postgres -d dev -c "CREATE TABLE IF NOT EXISTS users (id SERIAL PRIMARY KEY, name TEXT);"
setup-env:
@echo "Setting up environment variables..."
cp .env.example .env
# Ensure variables are set
[[ ! -z "$$(grep -c 'DB_HOST=.*db' .env)" ]] || echo "ERROR: DB_HOST not set in .env" >&2
apply-security-policies:
@echo "Applying security policies..."
# Check for .security/policies directory
[[ -d .security/policies ]] || {
echo "ERROR: .security/policies directory not found" >&2
exit 1
}
# Apply all policy files
for policy in .security/policies/*.json; do
[[ -f "$$policy" ]] || continue
jq -s '{policies: [.[].policy]} | .policies |= [.[].policy]' < "$$policy" > .security/policies/merged.json
done
Each project includes a .security/policies directory with JSON policy files. These files define security rules for CI/CD, container images, and runtime. The apply-security-policies target merges all policies into a single merged.json file, which is used by the CI pipeline.
A common failure is forgetting to set DB_HOST in .env, causing the database connection to fail at runtime. The make init command assumes docker-compose.yml exists and defines a service named db. If the service is named postgres instead, the database is created but not accessible, leading to a subtle psql: could not connect to server error.
Every project includes a GitHub Actions workflow in .github/workflows/ci.yml. The onboarding guide explains how to modify this file to add security checks.
# .github/workflows/ci.yml
name: CI
on:
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: |
pip install -r requirements.txt
pip install -r tests/requirements.txt
- name: Run tests
run: pytest tests/
- name: Run dependency scanning
run: |
pip install pip-audit
pip-audit --check --output-format json > audit-report.json
- name: Run container image scanning
run: |
docker build -t myapp:latest .
trivy image --exit-code 1 myapp:latest
- name: Run SAST
run: |
bandit -f json -o bandit-report.json -r src/
# Upload report to GitHub
gh upload artifact bandit-report.json --repo ${{ github.repository }} --ref ${{ github.ref }}
- name: Apply security policy
run: |
# Check if policy file exists
[[ -f .security/policies/merged.json ]] || {
echo "ERROR: .security/policies/merged.json not found" >&2
exit 1
}
# Enforce policy
jq -n \
--argjson policies "$(cat .security/policies/merged.json)" \
--arg branch "$GITHUB_REF" \
'{
branch: $branch,
policies: $policies
} | .policies[] | select(.rule == "image-minimum-size") | .value | .min_size_mb
' > min-size.json
# Fail if image size < 50MB
min_size=$(cat min-size.json)
[[ $min_size -lt 50 ]] && echo "ERROR: Image size < 50MB" >&2 && exit 1
The trivy image --exit-code 1 command fails if any vulnerability is found, making it a hard gate. The bandit tool generates a JSON report, which is uploaded as a GitHub artifact. The CI workflow includes a step that reads the merged policy file and checks the image-minimum-size rule.
A subtle but common failure is the bandit report not being uploaded correctly. The gh upload artifact command requires gh to be installed and configured with gh auth login. Without this, the artifact is missing from the PR. The jq -n command assumes the policies array is at the root level; if it's nested under rules, the policy check fails silently.
The onboarding guide teaches engineers to use PR templates that include security metadata. A PULL_REQUEST_TEMPLATE.md file includes sections for security review, vulnerability summary, and policy compliance.
## Security Review
- [ ] This PR includes security testing results
- [ ] All vulnerabilities have been reviewed
- [ ] CI passed all security gates
### Vulnerability Summary
| CVE | Severity | Package | Fix Available |
|-----|----------|---------|---------------|
| CVE-2023-1234 | High | requests==2.31.0 | Yes |
### Policy Compliance
- [ ] All container images meet minimum size requirement
- [ ] All dependencies have been audited
- [ ] No new high-severity issues in SAST
### Suggested Actions
- [ ] Review all new security policies
- [ ] Update `.security/policies/` for next release
The CI pipeline adds a comment to each PR with security status. The script add-security-comment.sh uses curl to post to the GitHub REST API.
#!/bin/bash
# add-security-comment.sh
set -euo pipefail
PR_URL="$1"
STATUS="$2"
REPORT_JSON="$3"
# Read report
REPORT=$(jq -c < "$REPORT_JSON")
# Build comment body
COMMENT_BODY=$(cat <<EOF
### Security Status
- Status: $STATUS
- Report: $REPORT
EOF
)
# Post comment
curl -X POST \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "Accept: application/vnd.github+json" \
-H "Content-Type: application/json" \
-d "{\"body\": \"$COMMENT_BODY\"}" \
"$PR_URL/comments"
The script expects GITHUB_TOKEN to be set in the environment. If it’s not, the comment fails silently with a 401 error. The Accept header must include application/vnd.github+json, not just application/json, which is common in API clients. The jq -c command produces compact JSON, which is essential for the comment body.
Onboarding culminates in a security audit exercise. Engineers run a full audit of their project using trivy and bandit, generate a report, and submit it.
The command make audit runs the audit and produces a audit-report.md file.
audit: generate-audit-report
generate-audit-report:
@echo "Running security audit..."
# Run trivy
trivy image --exit-code 1 --severity HIGH,CRITICAL myapp:latest -o trivy-report.json
# Run bandit
bandit -f markdown -o bandit-report.md -r src/
# Generate combined report
cat > audit-report.md << 'EOF'
# Security Audit Report
## Overview
- Project: myapp
- Branch: $$(git rev-parse --abbrev-ref HEAD)
- Date: $$(date)
## Trivy Results
$(cat trivy-report.json | jq -r '.Results | .[] | .Vulnerabilities | .[] | "- [ ] $$.Title ($$.Severity) - $$.Severity"')
## Bandit Results
$(cat bandit-report.md)
EOF
The trivy image --exit-code 1 command fails if any high or critical vulnerability is found. The jq -r command in the trivy-report.json processing produces a plain-text list, which is included in the audit-report.md. The make audit command assumes trivy and bandit are in the PATH. If trivy is not installed, the audit fails with command not found: trivy.
A common issue is the bandit-report.md file not being included in the audit-report.md. The cat command does not preserve newlines properly, so the markdown table is flattened. The solution is to use cat -s or cat <(cat bandit-report.md).
When a new engineer encounters an issue, the onboarding guide provides a troubleshooting checklist.
make init fails with ERROR: DB_HOST not set in .env Diagnosis: Verify DB_HOST is in .env with grep DB_HOST .env. Fix: Edit .env to include DB_HOST=db.
ERROR: .security/policies/merged.json not found Diagnosis: Check that .security/policies exists and contains files. Fix: Run mkdir -p .security/policies && cp *.json .security/policies/.
Diagnosis: Check GITHUB_TOKEN and gh installation. Fix: Run gh auth login and export GITHUB_TOKEN.
trivy image --exit-code 1 returns exit code 1 but no output Diagnosis: Check trivy version and image existence. Fix: Run docker images myapp and trivy version.
Before the onboarding is complete, engineers must:
make audit and submit audit-report.mdadd-security-comment.sh.security/policies with at least one new ruleThe onboarding process is complete when the engineer has contributed a secure, well-documented change to the project, and all security artifacts are visible and consistent across the team.
This page was rewritten on 12 October 2026. It replaced a templated version that was not specific to its own title. How these pages are written and checked. If anything here is wrong, tell us at [email protected] and we will correct it.
We use cookies for analytics (Google Analytics) and advertising (Google AdSense) to improve your experience and support free content. Privacy Policy