@hybridlabor-api/aos 4.8.0 → 4.9.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/.agents/agents.md +1 -1
- package/.agents/nodes.json +1 -1
- package/.agents/vendor-manifest.json +23 -1
- package/.claude/agents/godmode-media-eventtech.md +1 -1
- package/.claude/hooks/conventional-commits.mjs +125 -0
- package/.claude/hooks/env-file-protection.mjs +105 -0
- package/.claude/hooks/go-gate.mjs +101 -81
- package/.claude/settings.json +13 -0
- package/.opencode/agents/godmode-media-eventtech.md +1 -1
- package/.opencode/plugins/bdb-aos.js +31 -4
- package/README.de.md +1 -1
- package/README.md +1 -1
- package/README.pt.md +1 -1
- package/THIRD_PARTY_NOTICES.md +88 -0
- package/docs/skills_table.md +1 -1
- package/installer.js +174 -46
- package/package.json +6 -2
- package/packages/aos-cli/README.md +80 -0
- package/packages/aos-cli/bin/aos-cli.mjs +134 -0
- package/packages/aos-cli/core-skills.json +12 -0
- package/packages/aos-cli/extensions/aos.ts +321 -0
- package/packages/aos-cli/package-lock.json +1923 -0
- package/packages/aos-cli/package.json +29 -0
- package/packages/aos-cli/scripts/check-theme.mjs +63 -0
- package/packages/aos-cli/themes/aos.json +97 -0
- package/scripts/build-plugin-manifest.mjs +131 -0
- package/scripts/validate-skills.mjs +81 -6
- package/skills/basic/ao-orchestrator/SKILL.md +116 -0
- package/skills/global_config/agenttrail/SKILL.md +6 -1
- package/skills/global_config/ask-tim/SKILL.md +4 -4
- package/skills/global_config/bash-script-generator/SKILL.md +201 -0
- package/skills/global_config/bash-script-generator/assets/templates/standard-template.sh +96 -0
- package/skills/global_config/bash-script-generator/docs/bash-scripting-guide.md +729 -0
- package/skills/global_config/bash-script-generator/docs/generation-best-practices.md +193 -0
- package/skills/global_config/bash-script-generator/docs/script-patterns.md +566 -0
- package/skills/global_config/bash-script-generator/docs/text-processing-guide.md +437 -0
- package/skills/global_config/bash-script-generator/examples/log-analyzer.sh +92 -0
- package/skills/global_config/bash-script-generator/scripts/generate_script_template.sh +123 -0
- package/skills/global_config/bash-script-generator/scripts/run_ci_checks.sh +172 -0
- package/skills/global_config/bash-script-generator/scripts/test_generator.sh +413 -0
- package/skills/global_config/bash-script-validator/SKILL.md +249 -0
- package/skills/global_config/bash-script-validator/docs/awk-reference.md +449 -0
- package/skills/global_config/bash-script-validator/docs/bash-reference.md +468 -0
- package/skills/global_config/bash-script-validator/docs/common-mistakes.md +623 -0
- package/skills/global_config/bash-script-validator/docs/grep-reference.md +395 -0
- package/skills/global_config/bash-script-validator/docs/regex-reference.md +391 -0
- package/skills/global_config/bash-script-validator/docs/sed-reference.md +454 -0
- package/skills/global_config/bash-script-validator/docs/shell-reference.md +463 -0
- package/skills/global_config/bash-script-validator/docs/shellcheck-reference.md +399 -0
- package/skills/global_config/bash-script-validator/examples/bad-bash.sh +55 -0
- package/skills/global_config/bash-script-validator/examples/bad-shell.sh +54 -0
- package/skills/global_config/bash-script-validator/examples/good-bash.sh +71 -0
- package/skills/global_config/bash-script-validator/examples/good-shell.sh +69 -0
- package/skills/global_config/bash-script-validator/scripts/run_ci_checks.sh +23 -0
- package/skills/global_config/bash-script-validator/scripts/shellcheck_wrapper.sh +174 -0
- package/skills/global_config/bash-script-validator/scripts/test_validate.sh +446 -0
- package/skills/global_config/bash-script-validator/scripts/validate.sh +512 -0
- package/skills/global_config/ci-pipeline/SKILL.md +135 -0
- package/skills/global_config/dispatching-parallel-agents/SKILL.md +170 -0
- package/skills/global_config/dockerfile-generator/SKILL.md +1038 -0
- package/skills/global_config/dockerfile-generator/examples/example.dockerignore +95 -0
- package/skills/global_config/dockerfile-generator/examples/golang-distroless.Dockerfile +34 -0
- package/skills/global_config/dockerfile-generator/examples/java-springboot.Dockerfile +45 -0
- package/skills/global_config/dockerfile-generator/examples/nextjs-production.Dockerfile +49 -0
- package/skills/global_config/dockerfile-generator/examples/nodejs-multistage.Dockerfile +55 -0
- package/skills/global_config/dockerfile-generator/examples/python-fastapi.Dockerfile +48 -0
- package/skills/global_config/dockerfile-generator/references/language_specific_guides.md +510 -0
- package/skills/global_config/dockerfile-generator/references/multistage_builds.md +570 -0
- package/skills/global_config/dockerfile-generator/references/optimization_patterns.md +492 -0
- package/skills/global_config/dockerfile-generator/references/security_best_practices.md +375 -0
- package/skills/global_config/dockerfile-generator/scripts/generate_dockerignore.sh +199 -0
- package/skills/global_config/dockerfile-generator/scripts/generate_golang.sh +172 -0
- package/skills/global_config/dockerfile-generator/scripts/generate_java.sh +185 -0
- package/skills/global_config/dockerfile-generator/scripts/generate_nodejs.sh +279 -0
- package/skills/global_config/dockerfile-generator/scripts/generate_python.sh +218 -0
- package/skills/global_config/dockerfile-generator/scripts/test_generator.sh +210 -0
- package/skills/global_config/dockerfile-validator/SKILL.md +300 -0
- package/skills/global_config/dockerfile-validator/examples/.dockerignore.example +34 -0
- package/skills/global_config/dockerfile-validator/examples/bad-example.Dockerfile +37 -0
- package/skills/global_config/dockerfile-validator/examples/golang-distroless.Dockerfile +50 -0
- package/skills/global_config/dockerfile-validator/examples/good-example.Dockerfile +52 -0
- package/skills/global_config/dockerfile-validator/examples/python-optimized.Dockerfile +53 -0
- package/skills/global_config/dockerfile-validator/examples/security-issues.Dockerfile +42 -0
- package/skills/global_config/dockerfile-validator/references/docker_best_practices.md +348 -0
- package/skills/global_config/dockerfile-validator/references/optimization_guide.md +473 -0
- package/skills/global_config/dockerfile-validator/references/security_checklist.md +208 -0
- package/skills/global_config/dockerfile-validator/scripts/dockerfile-validate.sh +699 -0
- package/skills/global_config/dockerfile-validator/scripts/test_validate.sh +35 -0
- package/skills/global_config/dockerfile-validator/tests/fixtures/copy-before-yarn-lock-read.Dockerfile +6 -0
- package/skills/global_config/dockerfile-validator/tests/fixtures/copy-before-yarn.Dockerfile +6 -0
- package/skills/global_config/dockerfile-validator/tests/fixtures/from-platform-nonroot.Dockerfile +7 -0
- package/skills/global_config/dockerfile-validator/tests/test_regression.sh +164 -0
- package/skills/global_config/finishing-a-development-branch/SKILL.md +228 -0
- package/skills/global_config/github-actions-generator/SKILL.md +353 -0
- package/skills/global_config/github-actions-generator/assets/templates/action/composite/action.yml +82 -0
- package/skills/global_config/github-actions-generator/assets/templates/action/docker/Dockerfile +25 -0
- package/skills/global_config/github-actions-generator/assets/templates/action/docker/action.yml +42 -0
- package/skills/global_config/github-actions-generator/assets/templates/action/docker/entrypoint.sh +27 -0
- package/skills/global_config/github-actions-generator/assets/templates/action/javascript/action.yml +33 -0
- package/skills/global_config/github-actions-generator/assets/templates/action/javascript/index.js +50 -0
- package/skills/global_config/github-actions-generator/assets/templates/action/javascript/package.json +27 -0
- package/skills/global_config/github-actions-generator/assets/templates/workflow/basic_workflow.yml +242 -0
- package/skills/global_config/github-actions-generator/assets/templates/workflow/reusable_workflow.yml +106 -0
- package/skills/global_config/github-actions-generator/examples/README.md +147 -0
- package/skills/global_config/github-actions-generator/examples/actions/setup-node-cached/action.yml +93 -0
- package/skills/global_config/github-actions-generator/examples/caching/docker-buildkit.yml +256 -0
- package/skills/global_config/github-actions-generator/examples/security/dependency-review.yml +62 -0
- package/skills/global_config/github-actions-generator/examples/security/sbom-attestation.yml +119 -0
- package/skills/global_config/github-actions-generator/examples/triggers/chatops-commands.yml +475 -0
- package/skills/global_config/github-actions-generator/examples/triggers/repository-dispatch.yml +418 -0
- package/skills/global_config/github-actions-generator/examples/triggers/workflow-orchestration.yml +404 -0
- package/skills/global_config/github-actions-generator/examples/workflows/docker-build-push.yml +68 -0
- package/skills/global_config/github-actions-generator/examples/workflows/go-ci.yml +161 -0
- package/skills/global_config/github-actions-generator/examples/workflows/monorepo-ci.yml +340 -0
- package/skills/global_config/github-actions-generator/examples/workflows/multi-environment-deploy.yml +406 -0
- package/skills/global_config/github-actions-generator/examples/workflows/nodejs-ci.yml +122 -0
- package/skills/global_config/github-actions-generator/examples/workflows/python-ci.yml +157 -0
- package/skills/global_config/github-actions-generator/examples/workflows/scheduled-tasks.yml +376 -0
- package/skills/global_config/github-actions-generator/references/advanced-triggers.md +917 -0
- package/skills/global_config/github-actions-generator/references/best-practices.md +755 -0
- package/skills/global_config/github-actions-generator/references/common-actions.md +715 -0
- package/skills/global_config/github-actions-generator/references/custom-actions.md +320 -0
- package/skills/global_config/github-actions-generator/references/expressions-and-contexts.md +688 -0
- package/skills/global_config/github-actions-generator/references/modern-features.md +421 -0
- package/skills/global_config/github-actions-generator/scripts/test_generator.sh +344 -0
- package/skills/global_config/github-actions-templates/SKILL.md +7 -0
- package/skills/global_config/github-actions-validator/SKILL.md +576 -0
- package/skills/global_config/github-actions-validator/examples/README.md +88 -0
- package/skills/global_config/github-actions-validator/examples/outdated-versions.yml +76 -0
- package/skills/global_config/github-actions-validator/examples/valid-ci.yml +79 -0
- package/skills/global_config/github-actions-validator/examples/with-errors.yml +47 -0
- package/skills/global_config/github-actions-validator/references/act_usage.md +233 -0
- package/skills/global_config/github-actions-validator/references/action_versions.md +122 -0
- package/skills/global_config/github-actions-validator/references/actionlint_usage.md +343 -0
- package/skills/global_config/github-actions-validator/references/common_errors.md +512 -0
- package/skills/global_config/github-actions-validator/references/modern_features.md +384 -0
- package/skills/global_config/github-actions-validator/references/runners.md +317 -0
- package/skills/global_config/github-actions-validator/scripts/install_tools.sh +113 -0
- package/skills/global_config/github-actions-validator/scripts/validate_workflow.sh +910 -0
- package/skills/global_config/github-actions-validator/tests/test_validate_workflow.sh +237 -0
- package/skills/global_config/makefile-generator/SKILL.md +614 -0
- package/skills/global_config/makefile-generator/assets/templates/.gitkeep +1 -0
- package/skills/global_config/makefile-generator/docs/makefile-structure.md +530 -0
- package/skills/global_config/makefile-generator/docs/optimization-guide.md +784 -0
- package/skills/global_config/makefile-generator/docs/patterns-guide.md +642 -0
- package/skills/global_config/makefile-generator/docs/security-guide.md +361 -0
- package/skills/global_config/makefile-generator/docs/targets-guide.md +642 -0
- package/skills/global_config/makefile-generator/docs/variables-guide.md +596 -0
- package/skills/global_config/makefile-generator/scripts/add_standard_targets.sh +539 -0
- package/skills/global_config/makefile-generator/scripts/generate_makefile_template.sh +690 -0
- package/skills/global_config/makefile-generator/test/test_helper_scripts.sh +190 -0
- package/skills/global_config/makefile-validator/SKILL.md +244 -0
- package/skills/global_config/makefile-validator/docs/bake-tool.md +1000 -0
- package/skills/global_config/makefile-validator/docs/best-practices.md +858 -0
- package/skills/global_config/makefile-validator/docs/common-mistakes.md +944 -0
- package/skills/global_config/makefile-validator/examples/bad-makefile.mk +77 -0
- package/skills/global_config/makefile-validator/examples/good-makefile.mk +103 -0
- package/skills/global_config/makefile-validator/scripts/test_validate.sh +382 -0
- package/skills/global_config/makefile-validator/scripts/validate_makefile.sh +712 -0
- package/skills/global_config/{MCP_Manage → mcp-manage}/SKILL.md +3 -3
- package/skills/global_config/requesting-code-review/SKILL.md +98 -0
- package/skills/global_config/requesting-code-review/code-reviewer.md +198 -0
- package/skills/global_config/using-git-worktrees/SKILL.md +170 -0
- package/skills/global_config/verification-before-completion/SKILL.md +123 -0
- package/skills/global_config/writing-plans/SKILL.md +126 -46
- package/skills/global_config/writing-plans-legacy/SKILL.md +139 -0
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
# Makefile Security Guide
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
This guide covers security best practices for Makefiles, including secrets management, input validation, shell injection prevention, and CI/CD security considerations.
|
|
6
|
+
|
|
7
|
+
## Secrets Management
|
|
8
|
+
|
|
9
|
+
### Never Commit Secrets
|
|
10
|
+
|
|
11
|
+
**DO NOT** hardcode credentials, API keys, or passwords in Makefiles:
|
|
12
|
+
|
|
13
|
+
```makefile
|
|
14
|
+
# WRONG: Hardcoded credentials
|
|
15
|
+
DB_PASSWORD := mysecretpassword
|
|
16
|
+
AWS_SECRET := AKIAIOSFODNN7EXAMPLE
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Use Environment Variables
|
|
20
|
+
|
|
21
|
+
Pass secrets via environment variables:
|
|
22
|
+
|
|
23
|
+
```makefile
|
|
24
|
+
# CORRECT: Environment variable with validation
|
|
25
|
+
DB_PASSWORD ?= $(error DB_PASSWORD is not set)
|
|
26
|
+
AWS_SECRET_KEY ?= $(error AWS_SECRET_KEY is not set)
|
|
27
|
+
|
|
28
|
+
deploy:
|
|
29
|
+
@echo "Deploying with credentials from environment..."
|
|
30
|
+
./deploy.sh
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Use .env Files (Not in Git)
|
|
34
|
+
|
|
35
|
+
```makefile
|
|
36
|
+
# Include .env file if it exists (never commit .env!)
|
|
37
|
+
-include .env
|
|
38
|
+
export
|
|
39
|
+
|
|
40
|
+
# Ensure .gitignore contains .env
|
|
41
|
+
.PHONY: check-env
|
|
42
|
+
check-env:
|
|
43
|
+
@grep -q '^\.env$$' .gitignore || echo "WARNING: Add .env to .gitignore!"
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Secrets from External Sources
|
|
47
|
+
|
|
48
|
+
**AWS Secrets Manager:**
|
|
49
|
+
|
|
50
|
+
```makefile
|
|
51
|
+
# Fetch secret at runtime, don't cache in Makefile variables
|
|
52
|
+
deploy:
|
|
53
|
+
@DB_PASSWORD=$$(aws secretsmanager get-secret-value \
|
|
54
|
+
--secret-id prod/db/password \
|
|
55
|
+
--query SecretString --output text) && \
|
|
56
|
+
./deploy.sh
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
**HashiCorp Vault:**
|
|
60
|
+
|
|
61
|
+
```makefile
|
|
62
|
+
deploy:
|
|
63
|
+
@DB_PASSWORD=$$(vault kv get -field=password secret/database) && \
|
|
64
|
+
./deploy.sh
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Shell Injection Prevention
|
|
68
|
+
|
|
69
|
+
### Input Validation
|
|
70
|
+
|
|
71
|
+
Always validate user-provided variables:
|
|
72
|
+
|
|
73
|
+
```makefile
|
|
74
|
+
# Validate PROJECT_NAME contains only safe characters
|
|
75
|
+
PROJECT_NAME := $(strip $(PROJECT_NAME))
|
|
76
|
+
ifneq ($(PROJECT_NAME),$(shell echo '$(PROJECT_NAME)' | tr -cd 'a-zA-Z0-9_-'))
|
|
77
|
+
$(error PROJECT_NAME contains invalid characters. Use only [a-zA-Z0-9_-])
|
|
78
|
+
endif
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Quote Variables in Shell Commands
|
|
82
|
+
|
|
83
|
+
```makefile
|
|
84
|
+
# WRONG: Unquoted variables - vulnerable to injection
|
|
85
|
+
process:
|
|
86
|
+
./script.sh $(USER_INPUT)
|
|
87
|
+
|
|
88
|
+
# CORRECT: Quoted variables
|
|
89
|
+
process:
|
|
90
|
+
./script.sh '$(USER_INPUT)'
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Avoid Shell Expansion of User Input
|
|
94
|
+
|
|
95
|
+
```makefile
|
|
96
|
+
# WRONG: Shell will interpret special characters
|
|
97
|
+
echo-input:
|
|
98
|
+
@echo $(MESSAGE)
|
|
99
|
+
|
|
100
|
+
# SAFER: Use printf with proper quoting
|
|
101
|
+
echo-input:
|
|
102
|
+
@printf '%s\n' '$(MESSAGE)'
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Dangerous Patterns to Avoid
|
|
106
|
+
|
|
107
|
+
```makefile
|
|
108
|
+
# NEVER do this - allows arbitrary command execution
|
|
109
|
+
run-command:
|
|
110
|
+
$(USER_COMMAND)
|
|
111
|
+
|
|
112
|
+
# NEVER pipe untrusted input to shell
|
|
113
|
+
execute:
|
|
114
|
+
echo $(INPUT) | sh
|
|
115
|
+
|
|
116
|
+
# NEVER use eval with user input
|
|
117
|
+
eval-input:
|
|
118
|
+
@eval $(USER_INPUT)
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Variable Expansion Security
|
|
122
|
+
|
|
123
|
+
### Simple vs Recursive Expansion
|
|
124
|
+
|
|
125
|
+
```makefile
|
|
126
|
+
# Use := for values that shouldn't be re-evaluated
|
|
127
|
+
SAFE_VALUE := $(shell whoami)
|
|
128
|
+
|
|
129
|
+
# = causes re-evaluation each time - potential for injection
|
|
130
|
+
# if EXTERNAL_VAR changes after assignment
|
|
131
|
+
UNSAFE_VALUE = $(EXTERNAL_VAR)
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Dollar Sign Escaping
|
|
135
|
+
|
|
136
|
+
When working with passwords containing `$`:
|
|
137
|
+
|
|
138
|
+
```makefile
|
|
139
|
+
# Password with $ sign - double the $ to escape
|
|
140
|
+
# If password is "pa$$word", set it as:
|
|
141
|
+
PASSWORD := pa$$$$word
|
|
142
|
+
|
|
143
|
+
# Or read from file where $ is already escaped
|
|
144
|
+
PASSWORD := $(shell cat .password | sed 's/\$$/\$\$\$\$/g')
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## File System Security
|
|
148
|
+
|
|
149
|
+
### Path Traversal Prevention
|
|
150
|
+
|
|
151
|
+
```makefile
|
|
152
|
+
# WRONG: User can specify "../../../etc/passwd"
|
|
153
|
+
read-file:
|
|
154
|
+
cat $(FILE_PATH)
|
|
155
|
+
|
|
156
|
+
# SAFER: Validate path is within expected directory
|
|
157
|
+
SAFE_DIR := ./data
|
|
158
|
+
read-file:
|
|
159
|
+
@case "$(FILE_PATH)" in \
|
|
160
|
+
$(SAFE_DIR)/*) cat "$(FILE_PATH)" ;; \
|
|
161
|
+
*) echo "ERROR: Invalid path" >&2; exit 1 ;; \
|
|
162
|
+
esac
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### Secure Temporary Files
|
|
166
|
+
|
|
167
|
+
```makefile
|
|
168
|
+
# Use mktemp for secure temporary files
|
|
169
|
+
process:
|
|
170
|
+
@TMPFILE=$$(mktemp) && \
|
|
171
|
+
trap 'rm -f "$$TMPFILE"' EXIT && \
|
|
172
|
+
./generate-config > "$$TMPFILE" && \
|
|
173
|
+
./process-config "$$TMPFILE"
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### File Permission Handling
|
|
177
|
+
|
|
178
|
+
```makefile
|
|
179
|
+
# Set restrictive permissions on sensitive files
|
|
180
|
+
install-config:
|
|
181
|
+
install -m 600 config.secret $(DESTDIR)/etc/myapp/
|
|
182
|
+
|
|
183
|
+
# Create directories with appropriate permissions
|
|
184
|
+
install-dirs:
|
|
185
|
+
install -d -m 700 $(DESTDIR)/var/lib/myapp/secrets
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
## CI/CD Security
|
|
189
|
+
|
|
190
|
+
### Avoid Logging Secrets
|
|
191
|
+
|
|
192
|
+
```makefile
|
|
193
|
+
# WRONG: Password visible in logs
|
|
194
|
+
deploy:
|
|
195
|
+
curl -u user:$(PASSWORD) https://api.example.com
|
|
196
|
+
|
|
197
|
+
# CORRECT: Suppress command echo
|
|
198
|
+
deploy:
|
|
199
|
+
@curl -u user:$(PASSWORD) https://api.example.com
|
|
200
|
+
|
|
201
|
+
# BEST: Use credential helper
|
|
202
|
+
deploy:
|
|
203
|
+
@curl --netrc-file ~/.netrc https://api.example.com
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
### Fail Securely
|
|
207
|
+
|
|
208
|
+
```makefile
|
|
209
|
+
# Use strict mode
|
|
210
|
+
SHELL := bash
|
|
211
|
+
.SHELLFLAGS := -eu -o pipefail -c
|
|
212
|
+
|
|
213
|
+
# Ensure sensitive operations fail closed
|
|
214
|
+
deploy:
|
|
215
|
+
@test -n "$(API_KEY)" || { echo "ERROR: API_KEY not set" >&2; exit 1; }
|
|
216
|
+
@./deploy.sh
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### Environment Isolation
|
|
220
|
+
|
|
221
|
+
```makefile
|
|
222
|
+
# Don't inherit all environment variables
|
|
223
|
+
# Only export what's needed
|
|
224
|
+
unexport HISTFILE
|
|
225
|
+
unexport AWS_SESSION_TOKEN
|
|
226
|
+
|
|
227
|
+
# Explicitly export required variables
|
|
228
|
+
export PATH
|
|
229
|
+
export HOME
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### Audit Logging
|
|
233
|
+
|
|
234
|
+
```makefile
|
|
235
|
+
AUDIT_LOG := /var/log/makefile-audit.log
|
|
236
|
+
|
|
237
|
+
audit-log = @echo "$$(date -Iseconds) [$(1)] $(2)" >> $(AUDIT_LOG)
|
|
238
|
+
|
|
239
|
+
deploy: check-permissions
|
|
240
|
+
$(call audit-log,DEPLOY,Starting deployment by $$USER)
|
|
241
|
+
./deploy.sh
|
|
242
|
+
$(call audit-log,DEPLOY,Deployment completed)
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
## Network Security
|
|
246
|
+
|
|
247
|
+
### Secure Downloads
|
|
248
|
+
|
|
249
|
+
```makefile
|
|
250
|
+
# Always verify downloads
|
|
251
|
+
CHECKSUM_FILE := checksums.sha256
|
|
252
|
+
|
|
253
|
+
download:
|
|
254
|
+
curl -fsSL -o package.tar.gz https://example.com/package.tar.gz
|
|
255
|
+
sha256sum -c $(CHECKSUM_FILE)
|
|
256
|
+
|
|
257
|
+
# Or use GPG verification
|
|
258
|
+
download-verified:
|
|
259
|
+
curl -fsSL -o package.tar.gz https://example.com/package.tar.gz
|
|
260
|
+
curl -fsSL -o package.tar.gz.asc https://example.com/package.tar.gz.asc
|
|
261
|
+
gpg --verify package.tar.gz.asc package.tar.gz
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
### TLS/HTTPS Only
|
|
265
|
+
|
|
266
|
+
```makefile
|
|
267
|
+
# Force HTTPS for all downloads
|
|
268
|
+
CURL_OPTS := --proto '=https' --tlsv1.2
|
|
269
|
+
|
|
270
|
+
download:
|
|
271
|
+
curl $(CURL_OPTS) -fsSL -o file.txt https://example.com/file.txt
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
## Container Security
|
|
275
|
+
|
|
276
|
+
### Don't Build as Root
|
|
277
|
+
|
|
278
|
+
```makefile
|
|
279
|
+
docker-build:
|
|
280
|
+
docker build --build-arg USER_ID=$$(id -u) --build-arg GROUP_ID=$$(id -g) -t myapp .
|
|
281
|
+
|
|
282
|
+
# In Dockerfile, create non-root user
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
### Scan Images for Vulnerabilities
|
|
286
|
+
|
|
287
|
+
```makefile
|
|
288
|
+
IMAGE := myapp:latest
|
|
289
|
+
|
|
290
|
+
.PHONY: docker-scan
|
|
291
|
+
docker-scan: docker-build
|
|
292
|
+
@if command -v trivy >/dev/null 2>&1; then \
|
|
293
|
+
trivy image --exit-code 1 --severity HIGH,CRITICAL $(IMAGE); \
|
|
294
|
+
else \
|
|
295
|
+
echo "WARNING: trivy not found, skipping security scan"; \
|
|
296
|
+
fi
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
### Don't Pass Secrets as Build Args
|
|
300
|
+
|
|
301
|
+
```makefile
|
|
302
|
+
# WRONG: Secret visible in image layers
|
|
303
|
+
docker-build:
|
|
304
|
+
docker build --build-arg API_KEY=$(API_KEY) -t myapp .
|
|
305
|
+
|
|
306
|
+
# CORRECT: Use build secrets (BuildKit)
|
|
307
|
+
docker-build:
|
|
308
|
+
DOCKER_BUILDKIT=1 docker build \
|
|
309
|
+
--secret id=api_key,src=.api_key \
|
|
310
|
+
-t myapp .
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
## Secure Defaults
|
|
314
|
+
|
|
315
|
+
### Modern Makefile Preamble
|
|
316
|
+
|
|
317
|
+
```makefile
|
|
318
|
+
# Secure and strict Makefile configuration
|
|
319
|
+
SHELL := bash
|
|
320
|
+
.SHELLFLAGS := -eu -o pipefail -c
|
|
321
|
+
.DELETE_ON_ERROR:
|
|
322
|
+
MAKEFLAGS += --warn-undefined-variables
|
|
323
|
+
MAKEFLAGS += --no-builtin-rules
|
|
324
|
+
|
|
325
|
+
# Prevent accidental exposure
|
|
326
|
+
unexport HISTFILE
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
### Require Explicit Targets
|
|
330
|
+
|
|
331
|
+
```makefile
|
|
332
|
+
# Prevent running all targets by accident
|
|
333
|
+
.PHONY: all
|
|
334
|
+
all:
|
|
335
|
+
@echo "Please specify a target. Run 'make help' for options."
|
|
336
|
+
@exit 1
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
## Security Checklist
|
|
340
|
+
|
|
341
|
+
Before committing a Makefile:
|
|
342
|
+
|
|
343
|
+
- [ ] No hardcoded credentials, API keys, or passwords
|
|
344
|
+
- [ ] Secrets loaded from environment or secret manager
|
|
345
|
+
- [ ] `.env` file listed in `.gitignore`
|
|
346
|
+
- [ ] User input is validated before use
|
|
347
|
+
- [ ] Shell commands use proper quoting
|
|
348
|
+
- [ ] No use of `eval` with external input
|
|
349
|
+
- [ ] Downloads verified with checksums or signatures
|
|
350
|
+
- [ ] Sensitive commands prefixed with `@` to hide from logs
|
|
351
|
+
- [ ] Temporary files created securely and cleaned up
|
|
352
|
+
- [ ] File permissions are appropriately restrictive
|
|
353
|
+
- [ ] Container builds don't expose secrets in layers
|
|
354
|
+
|
|
355
|
+
## References
|
|
356
|
+
|
|
357
|
+
- [OWASP Command Injection](https://owasp.org/www-community/attacks/Command_Injection)
|
|
358
|
+
- [CWE-78: Improper Neutralization of Special Elements](https://cwe.mitre.org/data/definitions/78.html)
|
|
359
|
+
- [GNU Make Security Considerations](https://www.gnu.org/software/make/manual/html_node/Environment.html)
|
|
360
|
+
- [Passing Credentials in GNU Make - Security Stack Exchange](https://security.stackexchange.com/questions/278120/passing-credentials-in-gnu-make)
|
|
361
|
+
- [GitGuardian - Secure Your Secrets with .env](https://blog.gitguardian.com/secure-your-secrets-with-env/)
|