Back to list
chandima

security

by chandima

0🍴 0📅 Jan 21, 2026

SKILL.md


name: security description: DevSecOps practices for CI/CD and infrastructure. Covers OIDC authentication, secrets management, supply chain security, container hardening, and security scanning.

DevSecOps Patterns

Security practices integrated into CI/CD pipelines and infrastructure.

Core Principles

  1. Security as Code - Policies in version control
  2. Shift Left - Scan early, fail fast
  3. Zero Trust - Verify everything, trust nothing
  4. Least Privilege - Minimal permissions always
  5. Immutable Infrastructure - Replace, don't patch

Authentication Hierarchy

MethodSecurityUse Case
OIDCBestCloud providers (AWS, GCP, Azure)
Short-lived tokensBetterAPI access, temporary creds
Repository secretsGoodThird-party services
Long-lived credentialsAvoidLegacy systems only

OIDC Authentication

GitHub Actions → AWS

permissions:
  id-token: write
  contents: read

steps:
  - uses: aws-actions/configure-aws-credentials@v4
    with:
      role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
      aws-region: us-east-1

AWS Trust Policy

resource "aws_iam_role" "github_actions" {
  assume_role_policy = jsonencode({
    Version = "2012-10-17"
    Statement = [{
      Effect = "Allow"
      Principal = {
        Federated = "arn:aws:iam::${account_id}:oidc-provider/token.actions.githubusercontent.com"
      }
      Action = "sts:AssumeRoleWithWebIdentity"
      Condition = {
        StringEquals = {
          "token.actions.githubusercontent.com:aud" = "sts.amazonaws.com"
        }
        StringLike = {
          "token.actions.githubusercontent.com:sub" = "repo:org/repo:*"
        }
      }
    }]
  })
}

Supply Chain Security

Pin Actions by SHA

# Bad - tag can be moved
- uses: actions/checkout@v4

# Good - immutable
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

Enable Dependabot

# .github/dependabot.yml
version: 2
updates:
  - package-ecosystem: github-actions
    directory: /
    schedule:
      interval: weekly

Sign Artifacts

- name: Sign image
  run: cosign sign --yes ghcr.io/${{ github.repository }}:${{ github.sha }}

SBOM Generation

- uses: anchore/sbom-action@v0
  with:
    image: ghcr.io/${{ github.repository }}:${{ github.sha }}

Secrets Management

By Platform

PlatformSecret StoreBest Practice
GitHub ActionsRepository secretsEnvironment protection rules
JenkinsCredentials pluginFolder-scoped credentials
TerraformExternal onlyVault / cloud secrets manager
DockerNever in imageRuntime injection

GitHub Actions

# Never echo secrets
- run: |
    echo "::add-mask::${{ secrets.API_KEY }}"

# Use environments for approval
jobs:
  deploy:
    environment: production  # Requires approval

Terraform

# Use external secrets manager
data "aws_secretsmanager_secret_version" "db" {
  secret_id = var.db_secret_id
}

# Never in state
resource "aws_db_instance" "main" {
  password = data.aws_secretsmanager_secret_version.db.secret_string
}

Container Security

Non-Root User (Required)

RUN addgroup -S app && adduser -S app -G app
USER app

Minimal Base Images

# Use distroless (no shell, minimal attack surface)
FROM gcr.io/distroless/nodejs20

No Secrets in Images

# Bad
COPY .env ./
ARG DATABASE_PASSWORD

# Good - runtime only
# docker run -e DATABASE_PASSWORD=...

Security Scanning

# Trivy scan in CI
- name: Scan image
  uses: aquasecurity/trivy-action@master
  with:
    image-ref: myimage:latest
    severity: 'CRITICAL,HIGH'
    exit-code: '1'

CI/CD Security Checklist

GitHub Actions

  • Explicit permissions: block
  • OIDC for cloud authentication
  • Actions pinned by SHA
  • Environment protection rules
  • No secrets in logs
  • Dependabot enabled

Docker

  • Non-root user
  • Distroless or minimal base
  • No secrets in build
  • Image scanning in CI
  • Signed images

Terraform

  • Remote state with encryption
  • State locking enabled
  • Secrets from external manager
  • prevent_destroy on critical resources
  • Plan review before apply

Security Scanning Tools

TypeToolIntegration
ContainerTrivy, GrypeCI action
DependenciesDependabot, SnykGitHub integration
IaCtfsec, checkovPre-commit / CI
SecretsGitleaks, TruffleHogPre-commit
SASTSemgrep, CodeQLGitHub Actions

Common Vulnerabilities

IssueFix
Exposed secretsExternal secrets manager + scanning
Root containersNon-root USER directive
Unpinned depsLockfiles + version pinning
Missing OIDCReplace long-lived credentials
No scanningAdd Trivy/Snyk to CI

Score

Total Score

45/100

Based on repository quality metrics

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

0/10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

0/5
タグ

1つ以上のタグが設定されている

0/5

Reviews

💬

Reviews coming soon