guardian-framework 0.1.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.
- package/LICENSE +21 -0
- package/README.md +463 -0
- package/dist/cli.js +12958 -0
- package/dist/exports.js +12765 -0
- package/package.json +61 -0
- package/templates/languages/go-patterns.md +411 -0
- package/templates/languages/java-patterns.md +545 -0
- package/templates/languages/python-patterns.md +312 -0
- package/templates/languages/rust-patterns.md +232 -0
- package/templates/languages/typescript-patterns.md +313 -0
- package/templates/pi/INDEX.md +437 -0
- package/templates/pi/agent/AGENTS.md +166 -0
- package/templates/pi/agents/architecture-coordinator.md +40 -0
- package/templates/pi/agents/architecture-validator.md +36 -0
- package/templates/pi/agents/bootstrap-implementer.md +37 -0
- package/templates/pi/agents/issue-factory.md +31 -0
- package/templates/pi/agents/operations-validator.md +32 -0
- package/templates/pi/agents/security-validator.md +33 -0
- package/templates/pi/architecture/CHANGELOG.md +78 -0
- package/templates/pi/architecture/decisions/ADR-template.md +76 -0
- package/templates/pi/architecture/diagrams/system-overview.md +159 -0
- package/templates/pi/architecture/modules/module-template.md +152 -0
- package/templates/pi/context/checklists.md +91 -0
- package/templates/pi/context/domain-workflow.md +180 -0
- package/templates/pi/context/output-formats.md +135 -0
- package/templates/pi/context/patterns-base.md +47 -0
- package/templates/pi/context/patterns.md +38 -0
- package/templates/pi/context/project.md +88 -0
- package/templates/pi/domain/exploration.md +93 -0
- package/templates/pi/domain/ubiquitous-language.md +24 -0
- package/templates/pi/extensions/architect-lib/generators.ts +528 -0
- package/templates/pi/extensions/architect-lib/helpers.ts +344 -0
- package/templates/pi/extensions/architect-lib/types.ts +117 -0
- package/templates/pi/extensions/architect.ts +1425 -0
- package/templates/pi/extensions/ask-user-question.ts +579 -0
- package/templates/pi/extensions/bash-guard.ts +556 -0
- package/templates/pi/extensions/config-reload.ts +115 -0
- package/templates/pi/extensions/coordinator.ts +304 -0
- package/templates/pi/extensions/curator.ts +543 -0
- package/templates/pi/extensions/domain-explorer.ts +990 -0
- package/templates/pi/extensions/filechanges.ts +656 -0
- package/templates/pi/extensions/goal-loop.ts +717 -0
- package/templates/pi/extensions/hooks.ts +452 -0
- package/templates/pi/extensions/kanban.ts +547 -0
- package/templates/pi/extensions/pipeline.ts +1246 -0
- package/templates/pi/extensions/plan-mode.ts +209 -0
- package/templates/pi/extensions/project-scaffolder.ts +284 -0
- package/templates/pi/extensions/read-only-mode.ts +192 -0
- package/templates/pi/extensions/redaction.ts +128 -0
- package/templates/pi/extensions/session-persistence.ts +174 -0
- package/templates/pi/extensions/slash-commands.ts +229 -0
- package/templates/pi/extensions/snippets.ts +201 -0
- package/templates/pi/extensions/validation-runner.ts +100 -0
- package/templates/pi/github/agents/architecture-coordinator.agent.md +27 -0
- package/templates/pi/github/agents/architecture-validator.agent.md +20 -0
- package/templates/pi/github/agents/bootstrap-implementer.agent.md +20 -0
- package/templates/pi/github/agents/epic-planner.agent.md +70 -0
- package/templates/pi/github/agents/issue-factory.agent.md +20 -0
- package/templates/pi/github/agents/operations-validator.agent.md +20 -0
- package/templates/pi/github/agents/security-validator.agent.md +20 -0
- package/templates/pi/github/copilot/settings.json +16 -0
- package/templates/pi/github/copilot-instructions.md +155 -0
- package/templates/pi/github/instructions/architecture.instructions.md +71 -0
- package/templates/pi/github/instructions/validation.instructions.md +69 -0
- package/templates/pi/github/workflows/01-planning-workflow.md +75 -0
- package/templates/pi/github/workflows/02-issue-generation-workflow.md +69 -0
- package/templates/pi/github/workflows/03-implementation-workflow.md +80 -0
- package/templates/pi/github/workflows/04-validation-workflow.md +68 -0
- package/templates/pi/preflight_report.json +99 -0
- package/templates/pi/prompts/blueprint-update.md +262 -0
- package/templates/pi/prompts/blueprint-validate.md +218 -0
- package/templates/pi/prompts/bug-fix.md +50 -0
- package/templates/pi/prompts/ci-blueprint.md +131 -0
- package/templates/pi/prompts/context-refresh.md +258 -0
- package/templates/pi/prompts/epic-plan.md +356 -0
- package/templates/pi/prompts/epic-template.md +186 -0
- package/templates/pi/prompts/feature-development.md +131 -0
- package/templates/pi/prompts/git-issues.md +243 -0
- package/templates/pi/prompts/hotfix.md +71 -0
- package/templates/pi/prompts/issue-closeout.md +342 -0
- package/templates/pi/prompts/issue-draft.md +218 -0
- package/templates/pi/prompts/issue-implementation-series.md +173 -0
- package/templates/pi/prompts/issue-merge.md +372 -0
- package/templates/pi/prompts/issue-template-set.md +392 -0
- package/templates/pi/prompts/issue-template.md +207 -0
- package/templates/pi/prompts/pattern-extract.md +269 -0
- package/templates/pi/prompts/plan-to-issues.md +430 -0
- package/templates/pi/prompts/refactoring.md +82 -0
- package/templates/pi/prompts/scope-analyzer.md +254 -0
- package/templates/pi/prompts/sync-check.md +230 -0
- package/templates/pi/scripts/categorize-issues.sh +171 -0
- package/templates/pi/scripts/ci/check_architecture_conformance.sh +748 -0
- package/templates/pi/scripts/ci/check_planning_packet.py +228 -0
- package/templates/pi/scripts/ci/run_hardening_stages.sh +264 -0
- package/templates/pi/scripts/ci/run_preflight.sh +649 -0
- package/templates/pi/scripts/ci/run_stage.sh +193 -0
- package/templates/pi/scripts/ci/stage_docs_policy.sh +82 -0
- package/templates/pi/scripts/ci/stage_integration.sh +3 -0
- package/templates/pi/scripts/ci/stage_lint.sh +130 -0
- package/templates/pi/scripts/ci/stage_migration_verify.sh +3 -0
- package/templates/pi/scripts/ci/stage_package_build.sh +3 -0
- package/templates/pi/scripts/ci/stage_release_readiness.sh +3 -0
- package/templates/pi/scripts/ci/stage_remaining.sh +242 -0
- package/templates/pi/scripts/ci/stage_security.sh +3 -0
- package/templates/pi/scripts/ci/stage_static_analysis.sh +114 -0
- package/templates/pi/scripts/ci/stage_unit.sh +119 -0
- package/templates/pi/scripts/ci/validate_agent_output.py +181 -0
- package/templates/pi/scripts/ci/validate_agent_output.sh +243 -0
- package/templates/pi/scripts/create-feature-branch.sh +136 -0
- package/templates/pi/scripts/create-mr.sh +117 -0
- package/templates/pi/scripts/fetch-issues.sh +131 -0
- package/templates/pi/scripts/generate-architecture.sh +161 -0
- package/templates/pi/scripts/git/close-epic.sh +69 -0
- package/templates/pi/scripts/git/close-issue.sh +35 -0
- package/templates/pi/scripts/git/create-tracking-issue.sh +174 -0
- package/templates/pi/scripts/git/link-issue-to-epic.sh +51 -0
- package/templates/pi/scripts/git/update-tracking-issue.sh +66 -0
- package/templates/pi/scripts/languages/go/validate-architecture.sh +139 -0
- package/templates/pi/scripts/languages/go/validate-canonical.sh +129 -0
- package/templates/pi/scripts/languages/go/validate-ci.sh +132 -0
- package/templates/pi/scripts/languages/go/validate-integration.sh +156 -0
- package/templates/pi/scripts/languages/go/validate-operations.sh +146 -0
- package/templates/pi/scripts/languages/go/validate-security.sh +135 -0
- package/templates/pi/scripts/languages/go/validate-tests.sh +125 -0
- package/templates/pi/scripts/languages/java/validate-annotations.sh +185 -0
- package/templates/pi/scripts/languages/java/validate-architecture.sh +159 -0
- package/templates/pi/scripts/languages/java/validate-canonical.sh +114 -0
- package/templates/pi/scripts/languages/java/validate-ci.sh +269 -0
- package/templates/pi/scripts/languages/java/validate-integration.sh +149 -0
- package/templates/pi/scripts/languages/java/validate-operations.sh +142 -0
- package/templates/pi/scripts/languages/java/validate-security.sh +174 -0
- package/templates/pi/scripts/languages/java/validate-spring-architecture.sh +227 -0
- package/templates/pi/scripts/languages/java/validate-tests.sh +159 -0
- package/templates/pi/scripts/languages/python/validate-architecture.sh +99 -0
- package/templates/pi/scripts/languages/python/validate-canonical.sh +124 -0
- package/templates/pi/scripts/languages/python/validate-ci.sh +130 -0
- package/templates/pi/scripts/languages/python/validate-integration.sh +119 -0
- package/templates/pi/scripts/languages/python/validate-operations.sh +107 -0
- package/templates/pi/scripts/languages/python/validate-security.sh +68 -0
- package/templates/pi/scripts/languages/python/validate-tests.sh +102 -0
- package/templates/pi/scripts/languages/rust/validate-architecture.sh +188 -0
- package/templates/pi/scripts/languages/rust/validate-canonical.sh +146 -0
- package/templates/pi/scripts/languages/rust/validate-ci.sh +147 -0
- package/templates/pi/scripts/languages/rust/validate-integration.sh +149 -0
- package/templates/pi/scripts/languages/rust/validate-operations.sh +154 -0
- package/templates/pi/scripts/languages/rust/validate-security.sh +153 -0
- package/templates/pi/scripts/languages/rust/validate-tests.sh +150 -0
- package/templates/pi/scripts/languages/typescript/validate-architecture.sh +157 -0
- package/templates/pi/scripts/languages/typescript/validate-canonical.sh +135 -0
- package/templates/pi/scripts/languages/typescript/validate-ci.sh +244 -0
- package/templates/pi/scripts/languages/typescript/validate-integration.sh +166 -0
- package/templates/pi/scripts/languages/typescript/validate-operations.sh +162 -0
- package/templates/pi/scripts/languages/typescript/validate-security.sh +169 -0
- package/templates/pi/scripts/languages/typescript/validate-tests.sh +158 -0
- package/templates/pi/scripts/merge-mr.sh +95 -0
- package/templates/pi/scripts/mr-validation.sh +228 -0
- package/templates/pi/scripts/validate-architecture-readiness.sh +153 -0
- package/templates/pi/scripts/validate-architecture.sh +22 -0
- package/templates/pi/scripts/validate-canonical.sh +22 -0
- package/templates/pi/scripts/validate-ci.sh +37 -0
- package/templates/pi/scripts/validate-integration.sh +22 -0
- package/templates/pi/scripts/validate-operations.sh +22 -0
- package/templates/pi/scripts/validate-security.sh +22 -0
- package/templates/pi/scripts/validate-tests.sh +22 -0
- package/templates/pi/scripts/validate-ubiquitous-language.sh +291 -0
- package/templates/pi/scripts/validation-cache.sh +139 -0
- package/templates/pi/skills/agents/architecture-coordinator.md +178 -0
- package/templates/pi/skills/agents/architecture-generator.md +79 -0
- package/templates/pi/skills/agents/architecture-validator.md +74 -0
- package/templates/pi/skills/agents/ci-mr-validator.md +46 -0
- package/templates/pi/skills/agents/code-developer.md +76 -0
- package/templates/pi/skills/agents/commit.md +46 -0
- package/templates/pi/skills/agents/curator.md +71 -0
- package/templates/pi/skills/agents/debug.md +59 -0
- package/templates/pi/skills/agents/documentation-maintainer.md +36 -0
- package/templates/pi/skills/agents/goal-loop.md +125 -0
- package/templates/pi/skills/agents/hooks.md +122 -0
- package/templates/pi/skills/agents/integration-validator.md +35 -0
- package/templates/pi/skills/agents/issue-creator.md +75 -0
- package/templates/pi/skills/agents/issue-factory.md +143 -0
- package/templates/pi/skills/agents/kanban.md +85 -0
- package/templates/pi/skills/agents/land.md +59 -0
- package/templates/pi/skills/agents/operations-validator.md +43 -0
- package/templates/pi/skills/agents/pipeline.md +113 -0
- package/templates/pi/skills/agents/plan-mode.md +77 -0
- package/templates/pi/skills/agents/pull.md +40 -0
- package/templates/pi/skills/agents/push.md +41 -0
- package/templates/pi/skills/agents/security-validator.md +85 -0
- package/templates/pi/skills/agents/session-persistence.md +119 -0
- package/templates/pi/skills/agents/slash-commands.md +117 -0
- package/templates/pi/skills/agents/snippets.md +99 -0
- package/templates/pi/skills/agents/subagent-registry.md +78 -0
- package/templates/pi/skills/agents/test-validator.md +42 -0
- package/templates/pi/skills/validators/architecture-validator.md +43 -0
- package/templates/pi/skills/validators/ci-validator.md +27 -0
- package/templates/pi/skills/validators/context-compaction.md +73 -0
- package/templates/pi/skills/validators/integration-validator.md +38 -0
- package/templates/pi/skills/validators/model-registry.md +96 -0
- package/templates/pi/skills/validators/operations-validator.md +34 -0
- package/templates/pi/skills/validators/security-guards.md +72 -0
- package/templates/pi/skills/validators/security-validator.md +41 -0
- package/templates/pi/skills/validators/system-prompt-tiers.md +69 -0
- package/templates/pi/skills/validators/test-validator.md +33 -0
- package/templates/pi/types.ts +62 -0
- package/templates/pi/validators/README.md +93 -0
- package/templates/pi/validators/default.toml +209 -0
- package/templates/pi/validators/spring.toml +142 -0
- package/templates/pi/workpad.md +53 -0
- package/templates/project/java/Dockerfile +14 -0
- package/templates/project/java/README.md +40 -0
- package/templates/project/java/pom.xml +132 -0
- package/templates/project/typescript/Dockerfile +15 -0
- package/templates/project/typescript/README.md +29 -0
- package/templates/project/typescript/package.json +23 -0
- package/templates/project/typescript/tsconfig.json +21 -0
- package/templates/workflow.md +123 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# ============================================================================
|
|
3
|
+
# validate-ci.sh — Go
|
|
4
|
+
# ============================================================================
|
|
5
|
+
set -euo pipefail
|
|
6
|
+
|
|
7
|
+
ERRORS=()
|
|
8
|
+
WARNINGS=()
|
|
9
|
+
PASS_COUNT=0
|
|
10
|
+
|
|
11
|
+
RED='\033[0;31m'
|
|
12
|
+
GREEN='\033[0;32m'
|
|
13
|
+
YELLOW='\033[1;33m'
|
|
14
|
+
NC='\033[0m'
|
|
15
|
+
|
|
16
|
+
pass() { echo -e "${GREEN}✅ PASS${NC} $1"; PASS_COUNT=$((PASS_COUNT + 1)); }
|
|
17
|
+
fail() { echo -e "${RED}❌ FAIL${NC} $1"; ERRORS+=("$1"); }
|
|
18
|
+
warn() { echo -e "${YELLOW}⚠️ WARN${NC} $1"; WARNINGS+=("$1"); }
|
|
19
|
+
|
|
20
|
+
echo "============================================"
|
|
21
|
+
echo " CI/MR Validation (Go)"
|
|
22
|
+
echo "============================================"
|
|
23
|
+
echo ""
|
|
24
|
+
|
|
25
|
+
# ---------------------------------------------------------------------------
|
|
26
|
+
# Build
|
|
27
|
+
# ---------------------------------------------------------------------------
|
|
28
|
+
echo "--- Build ---"
|
|
29
|
+
if [ -f "go.mod" ]; then
|
|
30
|
+
if go build ./... 2>/dev/null; then
|
|
31
|
+
pass "Build succeeded"
|
|
32
|
+
else
|
|
33
|
+
fail "Build failed"
|
|
34
|
+
fi
|
|
35
|
+
else
|
|
36
|
+
pass "No go.mod (not a Go module, skipping build)"
|
|
37
|
+
fi
|
|
38
|
+
|
|
39
|
+
# ---------------------------------------------------------------------------
|
|
40
|
+
# Tests
|
|
41
|
+
# ---------------------------------------------------------------------------
|
|
42
|
+
echo ""
|
|
43
|
+
echo "--- Tests ---"
|
|
44
|
+
if [ -f "go.mod" ]; then
|
|
45
|
+
TEST_FILES=$(find . -name "*_test.go" -not -path "./vendor/*" 2>/dev/null | wc -l | tr -d ' ')
|
|
46
|
+
if [ "$TEST_FILES" -gt 0 ]; then
|
|
47
|
+
if go test ./... -count=1 2>/dev/null; then
|
|
48
|
+
pass "All tests passed"
|
|
49
|
+
else
|
|
50
|
+
fail "Tests failed"
|
|
51
|
+
fi
|
|
52
|
+
else
|
|
53
|
+
pass "No test files found (skipped)"
|
|
54
|
+
fi
|
|
55
|
+
else
|
|
56
|
+
pass "No go.mod (skipping tests)"
|
|
57
|
+
fi
|
|
58
|
+
|
|
59
|
+
# ---------------------------------------------------------------------------
|
|
60
|
+
# Lint
|
|
61
|
+
# ---------------------------------------------------------------------------
|
|
62
|
+
echo ""
|
|
63
|
+
echo "--- Lint ---"
|
|
64
|
+
if command -v golangci-lint &>/dev/null && [ -f "go.mod" ]; then
|
|
65
|
+
if golangci-lint run 2>/dev/null; then
|
|
66
|
+
pass "Lint passed"
|
|
67
|
+
else
|
|
68
|
+
fail "Lint failed"
|
|
69
|
+
fi
|
|
70
|
+
elif command -v go &>/dev/null && [ -f "go.mod" ]; then
|
|
71
|
+
if go vet ./... 2>/dev/null; then
|
|
72
|
+
pass "go vet passed"
|
|
73
|
+
else
|
|
74
|
+
fail "go vet failed"
|
|
75
|
+
fi
|
|
76
|
+
else
|
|
77
|
+
warn "No Go lint tools available, skipping lint"
|
|
78
|
+
fi
|
|
79
|
+
|
|
80
|
+
# ---------------------------------------------------------------------------
|
|
81
|
+
# Format
|
|
82
|
+
# ---------------------------------------------------------------------------
|
|
83
|
+
echo ""
|
|
84
|
+
echo "--- Format ---"
|
|
85
|
+
if command -v gofmt &>/dev/null && [ -f "go.mod" ]; then
|
|
86
|
+
FMT_OUT=$(gofmt -d . 2>/dev/null | grep -c . || true)
|
|
87
|
+
if [ "$FMT_OUT" -eq 0 ]; then
|
|
88
|
+
pass "Format check passed"
|
|
89
|
+
else
|
|
90
|
+
fail "Format check failed (${FMT_OUT} files need formatting)"
|
|
91
|
+
fi
|
|
92
|
+
else
|
|
93
|
+
warn "gofmt not available, skipping format check"
|
|
94
|
+
fi
|
|
95
|
+
|
|
96
|
+
# ---------------------------------------------------------------------------
|
|
97
|
+
# Security Audit
|
|
98
|
+
# ---------------------------------------------------------------------------
|
|
99
|
+
echo ""
|
|
100
|
+
echo "--- Security Audit ---"
|
|
101
|
+
if command -v govulncheck &>/dev/null && [ -f "go.mod" ]; then
|
|
102
|
+
VULN_OUT=$(govulncheck ./... 2>&1 || true)
|
|
103
|
+
if echo "$VULN_OUT" | grep -q "No vulnerabilities found"; then
|
|
104
|
+
pass "No known vulnerabilities"
|
|
105
|
+
else
|
|
106
|
+
warn "govulncheck reported findings (review manually)"
|
|
107
|
+
fi
|
|
108
|
+
else
|
|
109
|
+
warn "govulncheck not available, skipping vulnerability audit"
|
|
110
|
+
fi
|
|
111
|
+
|
|
112
|
+
# ---------------------------------------------------------------------------
|
|
113
|
+
# Summary
|
|
114
|
+
# ---------------------------------------------------------------------------
|
|
115
|
+
echo ""
|
|
116
|
+
echo "============================================"
|
|
117
|
+
echo " Summary"
|
|
118
|
+
echo "============================================"
|
|
119
|
+
echo -e " Passed: ${GREEN}${PASS_COUNT}${NC}"
|
|
120
|
+
echo -e " Failed: ${RED}${#ERRORS[@]}${NC}"
|
|
121
|
+
echo ""
|
|
122
|
+
|
|
123
|
+
if [ ${#ERRORS[@]} -gt 0 ]; then
|
|
124
|
+
echo "FAILURES:"
|
|
125
|
+
for err in "${ERRORS[@]}"; do
|
|
126
|
+
echo " - $err"
|
|
127
|
+
done
|
|
128
|
+
exit 1
|
|
129
|
+
fi
|
|
130
|
+
|
|
131
|
+
echo -e "${GREEN}All CI checks passed.${NC}"
|
|
132
|
+
exit 0
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# ============================================================================
|
|
3
|
+
# validate-integration.sh — Go
|
|
4
|
+
# ============================================================================
|
|
5
|
+
set -euo pipefail
|
|
6
|
+
|
|
7
|
+
PASS_COUNT=0; ERRORS=(); WARNINGS=()
|
|
8
|
+
RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'; NC='\033[0m'
|
|
9
|
+
pass() { echo -e "${GREEN}✅ PASS${NC} $1"; PASS_COUNT=$((PASS_COUNT + 1)); }
|
|
10
|
+
fail() { echo -e "${RED}❌ FAIL${NC} $1"; ERRORS+=("$1"); }
|
|
11
|
+
warn() { echo -e "${YELLOW}⚠️ WARN${NC} $1"; WARNINGS+=("$1"); }
|
|
12
|
+
|
|
13
|
+
echo "============================================"
|
|
14
|
+
echo " Integration Validation (Go)"
|
|
15
|
+
echo "============================================"
|
|
16
|
+
echo ""
|
|
17
|
+
|
|
18
|
+
# ---------------------------------------------------------------------------
|
|
19
|
+
# Integration Test Runner
|
|
20
|
+
# ---------------------------------------------------------------------------
|
|
21
|
+
echo "--- Integration Test Runner ---"
|
|
22
|
+
if [ -f "go.mod" ]; then
|
|
23
|
+
HAS_INTEGRATION=false
|
|
24
|
+
# Check for dedicated integration test files
|
|
25
|
+
if find . -name "*_integration_test.go" -not -path "./vendor/*" 2>/dev/null | grep -q .; then
|
|
26
|
+
HAS_INTEGRATION=true
|
|
27
|
+
fi
|
|
28
|
+
# Check for tests/integration directory
|
|
29
|
+
if [ -d "tests/integration" ]; then
|
|
30
|
+
HAS_INTEGRATION=true
|
|
31
|
+
fi
|
|
32
|
+
# Check for integration build tag
|
|
33
|
+
if grep -rl '//go:build integration' --include="*_test.go" . 2>/dev/null | grep -q .; then
|
|
34
|
+
HAS_INTEGRATION=true
|
|
35
|
+
fi
|
|
36
|
+
if [ "$HAS_INTEGRATION" = true ]; then
|
|
37
|
+
if go test -tags=integration ./... -count=1 2>/dev/null; then
|
|
38
|
+
pass "Integration tests passed"
|
|
39
|
+
else
|
|
40
|
+
fail "Integration tests failed"
|
|
41
|
+
fi
|
|
42
|
+
else
|
|
43
|
+
pass "No integration test files found (skipped)"
|
|
44
|
+
fi
|
|
45
|
+
else
|
|
46
|
+
pass "No go.mod (skipping integration tests)"
|
|
47
|
+
fi
|
|
48
|
+
|
|
49
|
+
# ---------------------------------------------------------------------------
|
|
50
|
+
# Docker/Compose Dependencies
|
|
51
|
+
# ---------------------------------------------------------------------------
|
|
52
|
+
echo ""
|
|
53
|
+
echo "--- Docker/Compose Dependencies ---"
|
|
54
|
+
if [ -f "docker-compose.yml" ] || [ -f "docker-compose.yaml" ]; then
|
|
55
|
+
warn "Docker Compose file found; integration tests may require running services"
|
|
56
|
+
elif [ -f "Dockerfile" ]; then
|
|
57
|
+
warn "Dockerfile found; integration tests may require containerized environment"
|
|
58
|
+
else
|
|
59
|
+
pass "No Docker Compose files found"
|
|
60
|
+
fi
|
|
61
|
+
|
|
62
|
+
# ---------------------------------------------------------------------------
|
|
63
|
+
# Contract Tests
|
|
64
|
+
# ---------------------------------------------------------------------------
|
|
65
|
+
echo ""
|
|
66
|
+
echo "--- Contract Tests ---"
|
|
67
|
+
if [ -f "go.mod" ]; then
|
|
68
|
+
CONTRACT_FILES=$(find . -name "*_contract_test.go" -not -path "./vendor/*" 2>/dev/null | wc -l | tr -d ' ')
|
|
69
|
+
if [ "$CONTRACT_FILES" -gt 0 ]; then
|
|
70
|
+
pass "Contract test files found ($CONTRACT_FILES files)"
|
|
71
|
+
else
|
|
72
|
+
warn "No contract test files (*_contract_test.go) found"
|
|
73
|
+
fi
|
|
74
|
+
else
|
|
75
|
+
pass "No Go source files to check"
|
|
76
|
+
fi
|
|
77
|
+
|
|
78
|
+
# ---------------------------------------------------------------------------
|
|
79
|
+
# Mock/Stub Detection
|
|
80
|
+
# ---------------------------------------------------------------------------
|
|
81
|
+
echo ""
|
|
82
|
+
echo "--- Mock/Stub Detection ---"
|
|
83
|
+
if [ -f "go.mod" ]; then
|
|
84
|
+
MOCK_PATTERNS=0
|
|
85
|
+
grep -qE '"github.com/golang/mock' . -r --include="*.go" 2>/dev/null && MOCK_PATTERNS=$((MOCK_PATTERNS + 1))
|
|
86
|
+
grep -qE '"github.com/stretchr/testify/mock"' . -r --include="*.go" 2>/dev/null && MOCK_PATTERNS=$((MOCK_PATTERNS + 1))
|
|
87
|
+
grep -qE '"go.uber.org/mock' . -r --include="*.go" 2>/dev/null && MOCK_PATTERNS=$((MOCK_PATTERNS + 1))
|
|
88
|
+
# Check for manual mock directories
|
|
89
|
+
if [ -d "mock" ] || [ -d "mocks" ] || find . -name "mock_*" -path "*/test*" 2>/dev/null | grep -q .; then
|
|
90
|
+
MOCK_PATTERNS=$((MOCK_PATTERNS + 1))
|
|
91
|
+
fi
|
|
92
|
+
if [ "$MOCK_PATTERNS" -gt 0 ]; then
|
|
93
|
+
pass "Mock/stub patterns detected ($MOCK_PATTERNS approaches found)"
|
|
94
|
+
else
|
|
95
|
+
warn "No mock/stub patterns detected (consider gomock or testify/mock)"
|
|
96
|
+
fi
|
|
97
|
+
else
|
|
98
|
+
warn "Not in a Go module, skipping mock detection"
|
|
99
|
+
fi
|
|
100
|
+
|
|
101
|
+
# ---------------------------------------------------------------------------
|
|
102
|
+
# Database Integration
|
|
103
|
+
# ---------------------------------------------------------------------------
|
|
104
|
+
echo ""
|
|
105
|
+
echo "--- Database Integration ---"
|
|
106
|
+
if [ -f "go.mod" ]; then
|
|
107
|
+
DB_TEST_FILES=0
|
|
108
|
+
find . -name "*_integration_test.go" -not -path "./vendor/*" 2>/dev/null | grep -q . && DB_TEST_FILES=$((DB_TEST_FILES + 1))
|
|
109
|
+
find . -name "*db_test.go" -not -path "./vendor/*" 2>/dev/null | grep -q . && DB_TEST_FILES=$((DB_TEST_FILES + 1))
|
|
110
|
+
find . -name "*repository*_test.go" -not -path "./vendor/*" 2>/dev/null | grep -q . && DB_TEST_FILES=$((DB_TEST_FILES + 1))
|
|
111
|
+
if [ "$DB_TEST_FILES" -gt 0 ]; then
|
|
112
|
+
pass "Database integration test patterns found ($DB_TEST_FILES patterns)"
|
|
113
|
+
else
|
|
114
|
+
warn "No database integration test files found (*_integration_test.go, *db_test.go)"
|
|
115
|
+
fi
|
|
116
|
+
else
|
|
117
|
+
pass "No Go source files to check"
|
|
118
|
+
fi
|
|
119
|
+
|
|
120
|
+
# ---------------------------------------------------------------------------
|
|
121
|
+
# HTTP Integration
|
|
122
|
+
# ---------------------------------------------------------------------------
|
|
123
|
+
echo ""
|
|
124
|
+
echo "--- HTTP Integration ---"
|
|
125
|
+
if [ -f "go.mod" ]; then
|
|
126
|
+
HTTPTEST_COUNT=$(grep -rl '"net/http/httptest"' . --include="*.go" 2>/dev/null | wc -l | tr -d ' ')
|
|
127
|
+
if [ "$HTTPTEST_COUNT" -gt 0 ]; then
|
|
128
|
+
pass "HTTP integration tests found (httptest in $HTTPTEST_COUNT files)"
|
|
129
|
+
else
|
|
130
|
+
warn "No httptest usage found (consider net/http/httptest for HTTP integration tests)"
|
|
131
|
+
fi
|
|
132
|
+
else
|
|
133
|
+
pass "No Go source files to check"
|
|
134
|
+
fi
|
|
135
|
+
|
|
136
|
+
# ---------------------------------------------------------------------------
|
|
137
|
+
# Summary
|
|
138
|
+
# ---------------------------------------------------------------------------
|
|
139
|
+
echo ""
|
|
140
|
+
echo "============================================"
|
|
141
|
+
echo " Summary"
|
|
142
|
+
echo "============================================"
|
|
143
|
+
echo -e " Passed: ${GREEN}${PASS_COUNT}${NC}"
|
|
144
|
+
echo -e " Failed: ${RED}${#ERRORS[@]}${NC}"
|
|
145
|
+
echo ""
|
|
146
|
+
|
|
147
|
+
if [ ${#ERRORS[@]} -gt 0 ]; then
|
|
148
|
+
echo "FAILURES:"
|
|
149
|
+
for err in "${ERRORS[@]}"; do
|
|
150
|
+
echo " - $err"
|
|
151
|
+
done
|
|
152
|
+
exit 1
|
|
153
|
+
fi
|
|
154
|
+
|
|
155
|
+
echo -e "${GREEN}Integration validation passed.${NC}"
|
|
156
|
+
exit 0
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# ============================================================================
|
|
3
|
+
# validate-operations.sh — Go
|
|
4
|
+
# ============================================================================
|
|
5
|
+
set -euo pipefail
|
|
6
|
+
|
|
7
|
+
PASS_COUNT=0; ERRORS=(); WARNINGS=()
|
|
8
|
+
RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'; NC='\033[0m'
|
|
9
|
+
pass() { echo -e "${GREEN}✅ PASS${NC} $1"; PASS_COUNT=$((PASS_COUNT + 1)); }
|
|
10
|
+
fail() { echo -e "${RED}❌ FAIL${NC} $1"; ERRORS+=("$1"); }
|
|
11
|
+
warn() { echo -e "${YELLOW}⚠️ WARN${NC} $1"; WARNINGS+=("$1"); }
|
|
12
|
+
|
|
13
|
+
echo "============================================"
|
|
14
|
+
echo " Operations Validation (Go)"
|
|
15
|
+
echo "============================================"
|
|
16
|
+
echo ""
|
|
17
|
+
|
|
18
|
+
# ---------------------------------------------------------------------------
|
|
19
|
+
# Structured Logging
|
|
20
|
+
# ---------------------------------------------------------------------------
|
|
21
|
+
echo "--- Structured Logging ---"
|
|
22
|
+
if [ -f "go.mod" ]; then
|
|
23
|
+
LOG_FRAMEWORKS=""
|
|
24
|
+
grep -qE '"log/slog"' . -r --include="*.go" 2>/dev/null && LOG_FRAMEWORKS="${LOG_FRAMEWORKS:+$LOG_FRAMEWORKS, }slog"
|
|
25
|
+
grep -qE '"go.uber.org/zap"' . -r --include="*.go" 2>/dev/null && LOG_FRAMEWORKS="${LOG_FRAMEWORKS:+$LOG_FRAMEWORKS, }zap"
|
|
26
|
+
grep -qE '"github.com/sirupsen/logrus"' . -r --include="*.go" 2>/dev/null && LOG_FRAMEWORKS="${LOG_FRAMEWORKS:+$LOG_FRAMEWORKS, }logrus"
|
|
27
|
+
grep -qE '"github.com/rs/zerolog"' . -r --include="*.go" 2>/dev/null && LOG_FRAMEWORKS="${LOG_FRAMEWORKS:+$LOG_FRAMEWORKS, }zerolog"
|
|
28
|
+
if [ -n "$LOG_FRAMEWORKS" ]; then
|
|
29
|
+
pass "Structured logging found ($LOG_FRAMEWORKS)"
|
|
30
|
+
else
|
|
31
|
+
warn "No structured logging framework detected (consider slog, zap, logrus, or zerolog)"
|
|
32
|
+
fi
|
|
33
|
+
else
|
|
34
|
+
warn "Not in a Go module, skipping logging check"
|
|
35
|
+
fi
|
|
36
|
+
|
|
37
|
+
# ---------------------------------------------------------------------------
|
|
38
|
+
# Health Checks
|
|
39
|
+
# ---------------------------------------------------------------------------
|
|
40
|
+
echo ""
|
|
41
|
+
echo "--- Health Checks ---"
|
|
42
|
+
if [ -f "go.mod" ]; then
|
|
43
|
+
HEALTH_ENDPOINTS=$(grep -rE '("/health|/healthz|/ready|/readiness)' . --include="*.go" 2>/dev/null | wc -l | tr -d ' ')
|
|
44
|
+
if [ "$HEALTH_ENDPOINTS" -gt 0 ]; then
|
|
45
|
+
pass "Health/readiness endpoint handlers found ($HEALTH_ENDPOINTS references)"
|
|
46
|
+
else
|
|
47
|
+
warn "No health check endpoints found (/health, /healthz, /ready)"
|
|
48
|
+
fi
|
|
49
|
+
else
|
|
50
|
+
pass "No Go source files to check"
|
|
51
|
+
fi
|
|
52
|
+
|
|
53
|
+
# ---------------------------------------------------------------------------
|
|
54
|
+
# Graceful Shutdown
|
|
55
|
+
# ---------------------------------------------------------------------------
|
|
56
|
+
echo ""
|
|
57
|
+
echo "--- Graceful Shutdown ---"
|
|
58
|
+
if [ -f "go.mod" ]; then
|
|
59
|
+
SHUTDOWN_PATTERNS=0
|
|
60
|
+
grep -qE 'signal\.Notify' . -r --include="*.go" 2>/dev/null && SHUTDOWN_PATTERNS=$((SHUTDOWN_PATTERNS + 1))
|
|
61
|
+
grep -qE 'context\.WithCancel' . -r --include="*.go" 2>/dev/null && SHUTDOWN_PATTERNS=$((SHUTDOWN_PATTERNS + 1))
|
|
62
|
+
grep -qE 'defer\s+.*cancel' . -r --include="*.go" 2>/dev/null && SHUTDOWN_PATTERNS=$((SHUTDOWN_PATTERNS + 1))
|
|
63
|
+
if [ "$SHUTDOWN_PATTERNS" -gt 0 ]; then
|
|
64
|
+
pass "Graceful shutdown patterns found ($SHUTDOWN_PATTERNS patterns detected)"
|
|
65
|
+
else
|
|
66
|
+
warn "No graceful shutdown patterns found (signal.Notify, context.WithCancel, defer cleanup)"
|
|
67
|
+
fi
|
|
68
|
+
else
|
|
69
|
+
pass "No Go source files to check"
|
|
70
|
+
fi
|
|
71
|
+
|
|
72
|
+
# ---------------------------------------------------------------------------
|
|
73
|
+
# Metrics
|
|
74
|
+
# ---------------------------------------------------------------------------
|
|
75
|
+
echo ""
|
|
76
|
+
echo "--- Metrics ---"
|
|
77
|
+
if [ -f "go.mod" ]; then
|
|
78
|
+
METRICS_LIBS=""
|
|
79
|
+
grep -qE '"github.com/prometheus' . -r --include="*.go" 2>/dev/null && METRICS_LIBS="${METRICS_LIBS:+$METRICS_LIBS, }prometheus"
|
|
80
|
+
grep -qE '"go.opentelemetry.io' . -r --include="*.go" 2>/dev/null && METRICS_LIBS="${METRICS_LIBS:+$METRICS_LIBS, }opentelemetry"
|
|
81
|
+
grep -qE '"expvar"' . -r --include="*.go" 2>/dev/null && METRICS_LIBS="${METRICS_LIBS:+$METRICS_LIBS, }expvar"
|
|
82
|
+
if [ -n "$METRICS_LIBS" ]; then
|
|
83
|
+
pass "Metrics/telemetry libraries found ($METRICS_LIBS)"
|
|
84
|
+
else
|
|
85
|
+
warn "No metrics libraries detected (consider prometheus, opentelemetry, or expvar)"
|
|
86
|
+
fi
|
|
87
|
+
else
|
|
88
|
+
warn "Not in a Go module, skipping metrics check"
|
|
89
|
+
fi
|
|
90
|
+
|
|
91
|
+
# ---------------------------------------------------------------------------
|
|
92
|
+
# Error Wrapping
|
|
93
|
+
# ---------------------------------------------------------------------------
|
|
94
|
+
echo ""
|
|
95
|
+
echo "--- Error Wrapping ---"
|
|
96
|
+
if [ -f "go.mod" ]; then
|
|
97
|
+
WRAP_COUNT=$(grep -rE 'fmt\.Errorf\(.*%w' . --include="*.go" 2>/dev/null | wc -l | tr -d ' ')
|
|
98
|
+
if [ "$WRAP_COUNT" -gt 0 ]; then
|
|
99
|
+
pass "Error wrapping with %w found ($WRAP_COUNT usages)"
|
|
100
|
+
else
|
|
101
|
+
warn "No error wrapping patterns found (use fmt.Errorf(\"... %w\", err))"
|
|
102
|
+
fi
|
|
103
|
+
else
|
|
104
|
+
pass "No Go source files to check"
|
|
105
|
+
fi
|
|
106
|
+
|
|
107
|
+
# ---------------------------------------------------------------------------
|
|
108
|
+
# Configuration
|
|
109
|
+
# ---------------------------------------------------------------------------
|
|
110
|
+
echo ""
|
|
111
|
+
echo "--- Configuration ---"
|
|
112
|
+
if [ -f "go.mod" ]; then
|
|
113
|
+
CONFIG_PATTERNS=0
|
|
114
|
+
grep -qE '"github.com/spf13/viper"' . -r --include="*.go" 2>/dev/null && CONFIG_PATTERNS=$((CONFIG_PATTERNS + 1))
|
|
115
|
+
grep -qE '"github.com/kelseyhightower/envconfig"' . -r --include="*.go" 2>/dev/null && CONFIG_PATTERNS=$((CONFIG_PATTERNS + 1))
|
|
116
|
+
grep -qE 'os\.Getenv' . -r --include="*.go" 2>/dev/null && CONFIG_PATTERNS=$((CONFIG_PATTERNS + 1))
|
|
117
|
+
if [ "$CONFIG_PATTERNS" -gt 0 ]; then
|
|
118
|
+
pass "Configuration management patterns found ($CONFIG_PATTERNS approaches detected)"
|
|
119
|
+
else
|
|
120
|
+
warn "No configuration management patterns found (consider viper, envconfig, or os.Getenv with defaults)"
|
|
121
|
+
fi
|
|
122
|
+
else
|
|
123
|
+
warn "Not in a Go module, skipping configuration check"
|
|
124
|
+
fi
|
|
125
|
+
|
|
126
|
+
# ---------------------------------------------------------------------------
|
|
127
|
+
# Summary
|
|
128
|
+
# ---------------------------------------------------------------------------
|
|
129
|
+
echo ""
|
|
130
|
+
echo "============================================"
|
|
131
|
+
echo " Summary"
|
|
132
|
+
echo "============================================"
|
|
133
|
+
echo -e " Passed: ${GREEN}${PASS_COUNT}${NC}"
|
|
134
|
+
echo -e " Failed: ${RED}${#ERRORS[@]}${NC}"
|
|
135
|
+
echo ""
|
|
136
|
+
|
|
137
|
+
if [ ${#ERRORS[@]} -gt 0 ]; then
|
|
138
|
+
echo "FAILURES:"
|
|
139
|
+
for err in "${ERRORS[@]}"; do
|
|
140
|
+
echo " - $err"
|
|
141
|
+
done
|
|
142
|
+
exit 1
|
|
143
|
+
fi
|
|
144
|
+
|
|
145
|
+
echo -e "${GREEN}Operations validation passed.${NC}"
|
|
146
|
+
exit 0
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# ============================================================================
|
|
3
|
+
# validate-security.sh — Go
|
|
4
|
+
# ============================================================================
|
|
5
|
+
set -euo pipefail
|
|
6
|
+
|
|
7
|
+
PASS_COUNT=0; ERRORS=(); WARNINGS=()
|
|
8
|
+
RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'; NC='\033[0m'
|
|
9
|
+
pass() { echo -e "${GREEN}✅ PASS${NC} $1"; PASS_COUNT=$((PASS_COUNT + 1)); }
|
|
10
|
+
fail() { echo -e "${RED}❌ FAIL${NC} $1"; ERRORS+=("$1"); }
|
|
11
|
+
warn() { echo -e "${YELLOW}⚠️ WARN${NC} $1"; WARNINGS+=("$1"); }
|
|
12
|
+
|
|
13
|
+
echo "============================================"
|
|
14
|
+
echo " Security Scan (Go)"
|
|
15
|
+
echo "============================================"
|
|
16
|
+
echo ""
|
|
17
|
+
|
|
18
|
+
# ---------------------------------------------------------------------------
|
|
19
|
+
# Hardcoded Secrets
|
|
20
|
+
# ---------------------------------------------------------------------------
|
|
21
|
+
echo "--- Hardcoded Secrets ---"
|
|
22
|
+
if [ -f "go.mod" ]; then
|
|
23
|
+
SECRET_COUNT=$(grep -rE '(apiKey|secretKey|password|secret|token)\s*=\s*"[^"]{8,}"' . --include="*.go" 2>/dev/null \
|
|
24
|
+
| grep -v "_test.go" \
|
|
25
|
+
| grep -vE '(example|placeholder|dummy|TODO|FIXME)' \
|
|
26
|
+
| wc -l | tr -d ' ')
|
|
27
|
+
if [ "$SECRET_COUNT" -eq 0 ]; then
|
|
28
|
+
pass "No hardcoded secrets detected"
|
|
29
|
+
else
|
|
30
|
+
fail "Potential hardcoded secrets found ($SECRET_COUNT occurrences)"
|
|
31
|
+
fi
|
|
32
|
+
else
|
|
33
|
+
pass "No Go source files to check"
|
|
34
|
+
fi
|
|
35
|
+
|
|
36
|
+
# ---------------------------------------------------------------------------
|
|
37
|
+
# SQL/Query Injection
|
|
38
|
+
# ---------------------------------------------------------------------------
|
|
39
|
+
echo ""
|
|
40
|
+
echo "--- Injection Patterns ---"
|
|
41
|
+
if [ -f "go.mod" ]; then
|
|
42
|
+
# Check for db.Exec/db.Query combined with fmt.Sprintf (string interpolation into queries)
|
|
43
|
+
INJECT_COUNT=0
|
|
44
|
+
# Find files using db.Exec or db.Query with fmt.Sprintf
|
|
45
|
+
for file in $(grep -rlE '(db\.Exec|db\.Query)\s*\(\s*fmt\.Sprintf' . --include="*.go" 2>/dev/null); do
|
|
46
|
+
INJECT_COUNT=$((INJECT_COUNT + 1))
|
|
47
|
+
done
|
|
48
|
+
if [ "$INJECT_COUNT" -eq 0 ]; then
|
|
49
|
+
pass "No obvious SQL injection patterns (no Exec/Query with Sprintf)"
|
|
50
|
+
else
|
|
51
|
+
fail "Potential SQL injection patterns ($INJECT_COUNT files use Exec/Query with fmt.Sprintf)"
|
|
52
|
+
fi
|
|
53
|
+
else
|
|
54
|
+
pass "No Go source files to check"
|
|
55
|
+
fi
|
|
56
|
+
|
|
57
|
+
# ---------------------------------------------------------------------------
|
|
58
|
+
# Dependency Audit
|
|
59
|
+
# ---------------------------------------------------------------------------
|
|
60
|
+
echo ""
|
|
61
|
+
echo "--- Dependency Audit ---"
|
|
62
|
+
if command -v govulncheck &>/dev/null && [ -f "go.mod" ]; then
|
|
63
|
+
VULN_OUT=$(govulncheck ./... 2>&1 || true)
|
|
64
|
+
if echo "$VULN_OUT" | grep -q "No vulnerabilities found"; then
|
|
65
|
+
pass "No known vulnerabilities"
|
|
66
|
+
else
|
|
67
|
+
warn "govulncheck reported findings (review manually)"
|
|
68
|
+
fi
|
|
69
|
+
elif [ -f "go.mod" ]; then
|
|
70
|
+
DEP_COUNT=$(go list -m all 2>/dev/null | wc -l | tr -d ' ')
|
|
71
|
+
warn "govulncheck not available; $DEP_COUNT dependencies require manual review"
|
|
72
|
+
else
|
|
73
|
+
warn "Not in a Go module, skipping dependency audit"
|
|
74
|
+
fi
|
|
75
|
+
|
|
76
|
+
# ---------------------------------------------------------------------------
|
|
77
|
+
# TLS/HTTPS Usage
|
|
78
|
+
# ---------------------------------------------------------------------------
|
|
79
|
+
echo ""
|
|
80
|
+
echo "--- TLS/HTTPS Usage ---"
|
|
81
|
+
if [ -f "go.mod" ]; then
|
|
82
|
+
# Check for hardcoded http:// URLs in non-test files (excluding localhost and examples)
|
|
83
|
+
HTTP_URLS=$(grep -rE 'https?://[^"'\''`\s]+' . --include="*.go" 2>/dev/null \
|
|
84
|
+
| grep -v "_test.go" \
|
|
85
|
+
| grep -vE '(localhost|127\.0\.0\.1|example\.com|example\.org)' \
|
|
86
|
+
| grep -c 'http://' || true)
|
|
87
|
+
if [ "$HTTP_URLS" -eq 0 ]; then
|
|
88
|
+
pass "No production http:// URLs found (using https://)"
|
|
89
|
+
else
|
|
90
|
+
warn "Found $HTTP_URLS potential http:// URLs (consider https://)"
|
|
91
|
+
fi
|
|
92
|
+
else
|
|
93
|
+
pass "No Go source files to check"
|
|
94
|
+
fi
|
|
95
|
+
|
|
96
|
+
# ---------------------------------------------------------------------------
|
|
97
|
+
# Input Validation (HTML vs Text Template)
|
|
98
|
+
# ---------------------------------------------------------------------------
|
|
99
|
+
echo ""
|
|
100
|
+
echo "--- Input Validation ---"
|
|
101
|
+
if [ -f "go.mod" ]; then
|
|
102
|
+
TEXT_TEMPLATE=$(grep -rl '"text/template"' . --include="*.go" 2>/dev/null | grep -v "_test.go" | wc -l | tr -d ' ')
|
|
103
|
+
HTML_TEMPLATE=$(grep -rl '"html/template"' . --include="*.go" 2>/dev/null | wc -l | tr -d ' ')
|
|
104
|
+
if [ "$TEXT_TEMPLATE" -eq 0 ]; then
|
|
105
|
+
pass "No text/template usage in production code (html/template auto-escapes)"
|
|
106
|
+
elif [ "$HTML_TEMPLATE" -gt 0 ]; then
|
|
107
|
+
warn "Found text/template in $TEXT_TEMPLATE files; html/template used in $HTML_TEMPLATE files (prefer html/template for HTML output)"
|
|
108
|
+
else
|
|
109
|
+
fail "Found text/template in $TEXT_TEMPLATE production files (use html/template for HTML output)"
|
|
110
|
+
fi
|
|
111
|
+
else
|
|
112
|
+
pass "No Go source files to check"
|
|
113
|
+
fi
|
|
114
|
+
|
|
115
|
+
# ---------------------------------------------------------------------------
|
|
116
|
+
# Summary
|
|
117
|
+
# ---------------------------------------------------------------------------
|
|
118
|
+
echo ""
|
|
119
|
+
echo "============================================"
|
|
120
|
+
echo " Summary"
|
|
121
|
+
echo "============================================"
|
|
122
|
+
echo -e " Passed: ${GREEN}${PASS_COUNT}${NC}"
|
|
123
|
+
echo -e " Failed: ${RED}${#ERRORS[@]}${NC}"
|
|
124
|
+
echo ""
|
|
125
|
+
|
|
126
|
+
if [ ${#ERRORS[@]} -gt 0 ]; then
|
|
127
|
+
echo "FAILURES:"
|
|
128
|
+
for err in "${ERRORS[@]}"; do
|
|
129
|
+
echo " - $err"
|
|
130
|
+
done
|
|
131
|
+
exit 1
|
|
132
|
+
fi
|
|
133
|
+
|
|
134
|
+
echo -e "${GREEN}Security scan passed.${NC}"
|
|
135
|
+
exit 0
|