@kaademos/secure-sdlc 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/.claude/agents/ai-security-engineer.md +209 -0
  2. package/.claude/agents/appsec-engineer.md +131 -0
  3. package/.claude/agents/cloud-platform-engineer.md +119 -0
  4. package/.claude/agents/dev-lead.md +138 -0
  5. package/.claude/agents/grc-analyst.md +143 -0
  6. package/.claude/agents/product-manager.md +100 -0
  7. package/.claude/agents/release-manager.md +126 -0
  8. package/.claude/agents/security-champion.md +148 -0
  9. package/.cursor/rules/secure-sdlc.mdc +98 -0
  10. package/.github/workflows/secure-sdlc-gate.yml +325 -0
  11. package/CHANGELOG.md +49 -0
  12. package/CLAUDE.md +195 -0
  13. package/LICENSE +21 -0
  14. package/README.md +394 -0
  15. package/cli/bin/secure-sdlc.js +95 -0
  16. package/cli/src/commands/gate.js +129 -0
  17. package/cli/src/commands/init.js +219 -0
  18. package/cli/src/commands/install-mcp.js +121 -0
  19. package/cli/src/commands/kickoff.js +261 -0
  20. package/cli/src/commands/paths.js +33 -0
  21. package/cli/src/commands/review.js +53 -0
  22. package/cli/src/commands/status.js +122 -0
  23. package/cli/src/utils/banner.js +43 -0
  24. package/cli/src/utils/package-root.js +23 -0
  25. package/cli/src/utils/phase-detect.js +107 -0
  26. package/cli/src/utils/stack-detect.js +138 -0
  27. package/docs/templates/compliance-attestation.md +159 -0
  28. package/docs/templates/infra-security-review.md +133 -0
  29. package/docs/templates/release-sign-off.md +119 -0
  30. package/docs/templates/risk-register.md +72 -0
  31. package/docs/templates/sast-findings.md +110 -0
  32. package/docs/templates/security-requirements.md +98 -0
  33. package/docs/templates/test-security-report.md +143 -0
  34. package/docs/templates/threat-model.md +129 -0
  35. package/hooks/install.sh +37 -0
  36. package/hooks/pre-commit +208 -0
  37. package/hooks/pre-push +127 -0
  38. package/mcp/README.md +116 -0
  39. package/mcp/package.json +23 -0
  40. package/mcp/src/server.js +638 -0
  41. package/package.json +67 -0
  42. package/stacks/django.md +216 -0
  43. package/stacks/express.md +229 -0
  44. package/stacks/fastapi.md +247 -0
  45. package/stacks/nextjs.md +198 -0
  46. package/stacks/nodejs.md +28 -0
  47. package/stacks/rails.md +247 -0
  48. package/warp-workflows/README.md +25 -0
  49. package/warp-workflows/feature-kickoff.yaml +49 -0
  50. package/warp-workflows/pr-security-review.yaml +47 -0
  51. package/warp-workflows/release-gate.yaml +44 -0
  52. package/warp-workflows/sdlc-status.yaml +48 -0
  53. package/warp-workflows/threat-model.yaml +56 -0
@@ -0,0 +1,247 @@
1
+ # Ruby on Rails Security Profile
2
+
3
+ **Framework:** Ruby on Rails 7.x / 8.x
4
+ **Language:** Ruby 3.x
5
+ **ASVS Baseline:** L2
6
+
7
+ ---
8
+
9
+ ## Rails Security Defaults — Preserve Them
10
+
11
+ Rails ships with strong security defaults. The most common vulnerabilities come from
12
+ disabling or incorrectly configuring built-in protections.
13
+
14
+ ---
15
+
16
+ ## Authentication — Don't Roll Your Own
17
+
18
+ Use **Devise** (or Rails 8's built-in authentication generator) rather than building auth from scratch:
19
+
20
+ ```bash
21
+ # Rails 8 built-in generator
22
+ rails generate authentication
23
+ ```
24
+
25
+ ```ruby
26
+ # Devise — most common Rails auth solution
27
+ # Gemfile
28
+ gem 'devise'
29
+ gem 'devise-two-factor' # Add TOTP MFA
30
+
31
+ # In User model
32
+ class User < ApplicationRecord
33
+ devise :database_authenticatable, :registerable,
34
+ :recoverable, :rememberable, :validatable,
35
+ :lockable, # Account lockout after N failed attempts
36
+ :timeoutable, # Session timeout after inactivity
37
+ :trackable # Track login timestamps and IP
38
+
39
+ # Lockout configuration
40
+ # devise.rb initializer:
41
+ # config.maximum_attempts = 5
42
+ # config.unlock_strategy = :time
43
+ # config.unlock_in = 15.minutes
44
+ end
45
+ ```
46
+
47
+ ---
48
+
49
+ ## Strong Parameters — Always
50
+
51
+ Rails 4+ requires strong parameters. Never skip them:
52
+
53
+ ```ruby
54
+ # ✗ Mass assignment vulnerability — any field can be set
55
+ @user = User.new(params[:user])
56
+
57
+ # ✓ Strong parameters
58
+ class UsersController < ApplicationController
59
+ def create
60
+ @user = User.new(user_params)
61
+ ...
62
+ end
63
+
64
+ private
65
+
66
+ def user_params
67
+ # Only permit the fields you expect
68
+ params.require(:user).permit(:name, :email, :password, :password_confirmation)
69
+ # ✗ Never: params.require(:user).permit! — permits ALL attributes
70
+ end
71
+ end
72
+ ```
73
+
74
+ ---
75
+
76
+ ## CSRF Protection
77
+
78
+ Rails includes CSRF protection by default. Don't disable it:
79
+
80
+ ```ruby
81
+ # ✓ Default — keep this in ApplicationController
82
+ class ApplicationController < ActionController::Base
83
+ protect_from_forgery with: :exception # Raises on CSRF failure
84
+ # OR: :null_session — resets session (use only for API endpoints)
85
+ # OR: :reset_session — resets session
86
+ end
87
+
88
+ # For API-only controllers that use Bearer token auth (not cookies):
89
+ class Api::V1::BaseController < ActionController::API
90
+ # ActionController::API does NOT include CSRF protection by default
91
+ # Token-based auth (Authorization: Bearer) is CSRF-safe by design
92
+ # ✗ Never include protect_from_forgery :null_session on API controllers
93
+ # that are already protected by Bearer token validation
94
+ end
95
+ ```
96
+
97
+ ---
98
+
99
+ ## Access Control — Pundit or CanCanCan
100
+
101
+ Authorisation is not built into Rails. Use a policy library:
102
+
103
+ ```ruby
104
+ # Pundit
105
+ class PostPolicy < ApplicationPolicy
106
+ def show?
107
+ record.author == user # ✓ Object-level auth
108
+ end
109
+
110
+ def update?
111
+ record.author == user
112
+ end
113
+
114
+ def destroy?
115
+ record.author == user || user.admin?
116
+ end
117
+ end
118
+
119
+ class PostsController < ApplicationController
120
+ before_action :authenticate_user! # Devise: ensure user is logged in
121
+
122
+ def show
123
+ @post = Post.find(params[:id])
124
+ authorize @post # ✓ Will call PostPolicy#show? — raises Pundit::NotAuthorizedError if fails
125
+ render json: @post
126
+ end
127
+
128
+ # ✓ Add this to catch missing authorization calls
129
+ after_action :verify_authorized
130
+ end
131
+ ```
132
+
133
+ **Common mistake:** Forget `authorize @resource` in a controller action. `after_action :verify_authorized`
134
+ will catch this and raise an error in development, preventing it reaching production.
135
+
136
+ ---
137
+
138
+ ## SQL Injection
139
+
140
+ Rails ActiveRecord is safe by default. Injection is only possible with:
141
+
142
+ ```ruby
143
+ # ✓ Safe — ActiveRecord parameterises automatically
144
+ User.where(email: params[:email])
145
+ User.where(id: params[:id])
146
+
147
+ # ✗ Unsafe — string interpolation in where clause
148
+ User.where("email = '#{params[:email]}'") # SQL injection
149
+
150
+ # ✓ Safe — use ? or named params with raw where
151
+ User.where("email = ?", params[:email])
152
+ User.where("email = :email", email: params[:email])
153
+
154
+ # ✗ Unsafe — order() clause injection is less obvious
155
+ User.order(params[:sort_column]) # ✗ Attacker controls SQL ORDER BY
156
+
157
+ # ✓ Safe — whitelist sort columns
158
+ ALLOWED_SORT_COLUMNS = %w[name email created_at].freeze
159
+ sort_col = ALLOWED_SORT_COLUMNS.include?(params[:sort]) ? params[:sort] : 'created_at'
160
+ User.order(sort_col)
161
+ ```
162
+
163
+ ---
164
+
165
+ ## XSS — ERB Auto-Escaping
166
+
167
+ Rails ERB templates auto-escape HTML output. The risk is explicitly disabling it:
168
+
169
+ ```erb
170
+ <!-- ✓ Safe — auto-escaped -->
171
+ <%= @user.name %>
172
+
173
+ <!-- ✗ Unsafe — disables escaping -->
174
+ <%= raw @user.bio %>
175
+ <%== @user.bio %> # Also disables escaping
176
+
177
+ <!-- ✓ Safe HTML rendering — use sanitize for user-provided HTML -->
178
+ <%= sanitize @user.bio, tags: %w[p strong em a], attributes: %w[href] %>
179
+ ```
180
+
181
+ ---
182
+
183
+ ## Secrets Management — Rails Credentials
184
+
185
+ ```bash
186
+ # Rails 7+ encrypted credentials
187
+ rails credentials:edit
188
+
189
+ # Access in code
190
+ Rails.application.credentials.dig(:aws, :access_key_id)
191
+ Rails.application.credentials.secret_key_base
192
+
193
+ # ✓ Master key in .gitignore (already there by default)
194
+ # ✗ Never commit config/master.key
195
+ ```
196
+
197
+ For team environments, use per-environment credentials:
198
+
199
+ ```bash
200
+ rails credentials:edit --environment production
201
+ # Creates config/credentials/production.yml.enc + config/credentials/production.key
202
+ # Commit the .enc file, keep .key in your secrets manager
203
+ ```
204
+
205
+ ---
206
+
207
+ ## Brakeman — Rails SAST Tool
208
+
209
+ Run Brakeman on every PR. It understands Rails-specific patterns:
210
+
211
+ ```bash
212
+ gem install brakeman
213
+ brakeman --no-pager --format json > brakeman.json
214
+
215
+ # In CI (block on high confidence findings)
216
+ brakeman --exit-on-warn --confidence-level 2
217
+ ```
218
+
219
+ Brakeman detects: SQL injection, XSS, CSRF bypass, mass assignment, redirect injection,
220
+ session fixation, and many other Rails-specific issues.
221
+
222
+ ---
223
+
224
+ ## ASVS Controls for Rails Projects
225
+
226
+ | ASVS Ref | Control | Rails Implementation |
227
+ |----------|---------|---------------------|
228
+ | V2.1.1 | Password complexity | Devise validates :password strength |
229
+ | V2.2.1 | Account lockout | Devise :lockable |
230
+ | V4.1.1 | Auth on all actions | `before_action :authenticate_user!` |
231
+ | V4.2.1 | Object-level auth | Pundit policies with `authorize @resource` |
232
+ | V5.3.4 | No SQL injection | ActiveRecord ORM; never string-interpolate in where() |
233
+ | V14.4.5 | CSRF | `protect_from_forgery` (default) |
234
+
235
+ ---
236
+
237
+ ## Recommended Tools
238
+
239
+ | Category | Tool |
240
+ |----------|------|
241
+ | Auth | Devise, Rodauth |
242
+ | Authorisation | Pundit, CanCanCan |
243
+ | SAST | Brakeman |
244
+ | Dependency scan | bundler-audit |
245
+ | 2FA | devise-two-factor |
246
+ | Rate limiting | rack-attack |
247
+ | Secrets | Rails credentials, Doppler |
@@ -0,0 +1,25 @@
1
+ # Warp Terminal Workflows — Secure SDLC
2
+
3
+ Pre-built [Warp Workflows](https://docs.warp.dev/features/workflows) for the Secure SDLC agent team.
4
+ Workflows turn multi-step secure development processes into single-command executions in Warp.
5
+
6
+ ## Installation
7
+
8
+ 1. Open Warp terminal
9
+ 2. Press `Ctrl+Shift+R` to open Workflows
10
+ 3. Click "Import" and import each `.yaml` file from this directory
11
+
12
+ Or copy them to your Warp workflows directory:
13
+ ```bash
14
+ cp warp-workflows/*.yaml ~/.warp/workflows/
15
+ ```
16
+
17
+ ## Available Workflows
18
+
19
+ | Workflow | Description |
20
+ |---|---|
21
+ | `feature-kickoff.yaml` | Start a new feature with full Secure SDLC coverage |
22
+ | `pr-security-review.yaml` | Security review a pull request |
23
+ | `release-gate.yaml` | Run the pre-release security gate |
24
+ | `threat-model.yaml` | Kick off a threat modelling session |
25
+ | `sdlc-status.yaml` | Check current SDLC phase and artefact status |
@@ -0,0 +1,49 @@
1
+ ---
2
+ name: "Secure SDLC: Feature Kickoff"
3
+ command: |
4
+ # ── Secure SDLC Feature Kickoff ───────────────────────────────────────────
5
+ # Starts a new feature with ASVS requirements, risk register, and a threat
6
+ # model — the Plan and Design phases in one interactive session.
7
+ #
8
+ # Step 1: Initialise docs directory if not present
9
+ mkdir -p docs/audit-evidence
10
+
11
+ # Step 2: Generate security requirements (Plan phase)
12
+ echo "🔵 PLAN PHASE — Security Requirements"
13
+ claude --agent product-manager \
14
+ "Define security requirements for: {{feature_description}}. \
15
+ Stack: {{stack}}. \
16
+ ASVS Level: {{asvs_level}}. \
17
+ Compliance frameworks: {{compliance_frameworks}}. \
18
+ Save output to docs/security-requirements.md"
19
+
20
+ # Step 3: Initialise risk register
21
+ echo ""
22
+ echo "🔵 PLAN PHASE — Risk Register"
23
+ claude --agent grc-analyst \
24
+ "Initialise risk register for: {{feature_description}}. \
25
+ Map requirements from docs/security-requirements.md to compliance controls. \
26
+ Save output to docs/risk-register.md"
27
+
28
+ echo ""
29
+ echo "✅ Plan phase complete. Review docs/security-requirements.md and docs/risk-register.md"
30
+ echo ""
31
+ echo "Next: Design phase — run 'Secure SDLC: Threat Model' workflow after documenting your architecture."
32
+ tags:
33
+ - security
34
+ - sdlc
35
+ - plan
36
+ - requirements
37
+ arguments:
38
+ - name: feature_description
39
+ description: "What you're building (e.g. 'user authentication with email/password and TOTP MFA')"
40
+ default_value: ""
41
+ - name: stack
42
+ description: "Technology stack (e.g. 'Next.js + PostgreSQL', 'Python FastAPI + AWS')"
43
+ default_value: "Node.js"
44
+ - name: asvs_level
45
+ description: "ASVS level (L1/L2/L3)"
46
+ default_value: "L2"
47
+ - name: compliance_frameworks
48
+ description: "Compliance frameworks (e.g. 'SOC2, GDPR' or 'none')"
49
+ default_value: "none"
@@ -0,0 +1,47 @@
1
+ ---
2
+ name: "Secure SDLC: PR Security Review"
3
+ command: |
4
+ # ── Secure SDLC PR Security Review ─────────────────────────────────────────
5
+ # Runs dev-lead + appsec-engineer review on a pull request.
6
+ # Reference: docs/security-requirements.md for acceptance criteria.
7
+
8
+ echo "🟡 BUILD PHASE — PR Security Review #{{pr_number}}"
9
+ echo ""
10
+
11
+ # Dev Lead: secure coding review
12
+ echo "Dev Lead review..."
13
+ claude --agent dev-lead \
14
+ "Security review PR #{{pr_number}} — {{pr_description}}. \
15
+ Stack: {{stack}}. \
16
+ Reference security requirements in docs/security-requirements.md. \
17
+ Flag any CRITICAL or HIGH issues that must be fixed before merge. \
18
+ Note any new dependencies added."
19
+
20
+ echo ""
21
+ echo "AppSec triage..."
22
+
23
+ # AppSec Engineer: SAST triage and deeper vuln analysis
24
+ claude --agent appsec-engineer \
25
+ "Triage security findings for PR #{{pr_number}} — {{pr_description}}. \
26
+ Review dev-lead findings and add any additional vulnerability analysis. \
27
+ Update docs/sast-findings.md with any new findings."
28
+
29
+ echo ""
30
+ echo "✅ PR security review complete."
31
+ echo " CRITICAL/HIGH findings must be resolved before merge."
32
+ echo " MEDIUM findings should be resolved or risk-accepted before release."
33
+ tags:
34
+ - security
35
+ - sdlc
36
+ - build
37
+ - pr-review
38
+ arguments:
39
+ - name: pr_number
40
+ description: "Pull request number (e.g. '42')"
41
+ default_value: ""
42
+ - name: pr_description
43
+ description: "Brief description of what the PR does"
44
+ default_value: ""
45
+ - name: stack
46
+ description: "Technology stack"
47
+ default_value: ""
@@ -0,0 +1,44 @@
1
+ ---
2
+ name: "Secure SDLC: Release Gate"
3
+ command: |
4
+ # ── Secure SDLC Release Gate ────────────────────────────────────────────────
5
+ # Runs the full pre-release security checklist.
6
+ # ALL CRITICAL must be resolved. HIGH must be resolved or have accepted risk.
7
+
8
+ echo "🟢 RELEASE PHASE — Security Gate for {{version}}"
9
+ echo ""
10
+
11
+ # CLI gate check (artefact presence + open findings heuristic)
12
+ if command -v secure-sdlc &> /dev/null; then
13
+ secure-sdlc gate {{version}}
14
+ echo ""
15
+ fi
16
+
17
+ # Formal release manager sign-off
18
+ echo "Release Manager: formal go/no-go decision..."
19
+ claude --agent release-manager \
20
+ "Run pre-release security checklist for {{version}}. \
21
+ Check artefacts in docs/. \
22
+ Apply severity gates: CRITICAL = block, HIGH without accepted risk = block. \
23
+ Produce formal go/no-go decision and save to docs/release-security-sign-off.md."
24
+
25
+ echo ""
26
+
27
+ # GRC compliance attestation
28
+ echo "GRC Analyst: compliance attestation..."
29
+ claude --agent grc-analyst \
30
+ "Produce compliance attestation for {{version}}. \
31
+ Reference docs/risk-register.md and all phase artefacts. \
32
+ Save to docs/audit-evidence/compliance-attestation-{{version}}.md."
33
+
34
+ echo ""
35
+ echo "Release gate complete. Check docs/release-security-sign-off.md for the decision."
36
+ tags:
37
+ - security
38
+ - sdlc
39
+ - release
40
+ - gate
41
+ arguments:
42
+ - name: version
43
+ description: "Release version (e.g. 'v1.2.0')"
44
+ default_value: "v1.0.0"
@@ -0,0 +1,48 @@
1
+ ---
2
+ name: "Secure SDLC: Check Status"
3
+ command: |
4
+ # ── Secure SDLC Status Check ───────────────────────────────────────────────
5
+ # Shows which phases are complete and what's next.
6
+
7
+ if command -v secure-sdlc &> /dev/null; then
8
+ secure-sdlc status
9
+ else
10
+ echo "Checking SDLC artefacts manually..."
11
+ echo ""
12
+
13
+ check() {
14
+ if [ -f "$1" ]; then
15
+ echo " ✓ $1"
16
+ else
17
+ echo " ○ $1 (missing)"
18
+ fi
19
+ }
20
+
21
+ echo "PLAN:"
22
+ check "docs/security-requirements.md"
23
+ check "docs/risk-register.md"
24
+
25
+ echo ""
26
+ echo "DESIGN:"
27
+ check "docs/threat-model.md"
28
+ check "docs/infra-security-review.md"
29
+
30
+ echo ""
31
+ echo "BUILD:"
32
+ check "docs/sast-findings.md"
33
+
34
+ echo ""
35
+ echo "TEST:"
36
+ check "docs/test-security-report.md"
37
+
38
+ echo ""
39
+ echo "RELEASE:"
40
+ check "docs/release-security-sign-off.md"
41
+
42
+ echo ""
43
+ echo "Install the CLI for richer output: npm install -g secure-sdlc"
44
+ fi
45
+ tags:
46
+ - security
47
+ - sdlc
48
+ - status
@@ -0,0 +1,56 @@
1
+ ---
2
+ name: "Secure SDLC: Threat Model"
3
+ command: |
4
+ # ── Secure SDLC Threat Model ────────────────────────────────────────────────
5
+ # Runs a STRIDE threat model (+ optional LINDDUN) on your architecture.
6
+ # Prerequisites: docs/security-requirements.md must exist (run Plan phase first).
7
+
8
+ echo "🟣 DESIGN PHASE — Threat Model: {{feature_name}}"
9
+ echo ""
10
+
11
+ if [ ! -f "docs/security-requirements.md" ]; then
12
+ echo "⚠ docs/security-requirements.md not found."
13
+ echo " Run the 'Feature Kickoff' workflow first to generate requirements."
14
+ echo ""
15
+ fi
16
+
17
+ claude --agent appsec-engineer \
18
+ "Threat model {{feature_name}} using STRIDE. \
19
+ Architecture: {{architecture_description}}. \
20
+ {{pii_flag}} \
21
+ Reference security requirements in docs/security-requirements.md. \
22
+ Save threat model to docs/threat-model.md."
23
+
24
+ echo ""
25
+
26
+ if [ "{{has_infra}}" = "true" ]; then
27
+ echo "Cloud/Platform Engineer: infrastructure review..."
28
+ claude --agent cloud-platform-engineer \
29
+ "Review infrastructure design for {{feature_name}}: {{infra_description}}. \
30
+ Save review to docs/infra-security-review.md."
31
+ echo ""
32
+ fi
33
+
34
+ echo "✅ Design phase outputs saved to docs/."
35
+ echo " Review CRITICAL and HIGH threats before implementation begins."
36
+ tags:
37
+ - security
38
+ - sdlc
39
+ - design
40
+ - threat-model
41
+ arguments:
42
+ - name: feature_name
43
+ description: "Feature or system name being modelled"
44
+ default_value: ""
45
+ - name: architecture_description
46
+ description: "Architecture description: components, data flows, trust boundaries, protocols, auth"
47
+ default_value: ""
48
+ - name: pii_flag
49
+ description: "Set to 'Also run LINDDUN privacy threat model — PII is in scope.' if feature handles PII"
50
+ default_value: ""
51
+ - name: has_infra
52
+ description: "Include infrastructure review? (true/false)"
53
+ default_value: "false"
54
+ - name: infra_description
55
+ description: "Infrastructure description (if has_infra is true)"
56
+ default_value: ""