Skip to content

Commit ca46dc7

Browse files
refactor: move templates into src/data/ directory (#235)
Move pipeline templates from top-level templates/ into src/data/ alongside ecosystem_domains.json, keeping injected content separate from source code. Update all include paths, documentation, workflow path filters, and test references. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 418c4c6 commit ca46dc7

15 files changed

Lines changed: 39 additions & 38 deletions

.github/workflows/doc-freshness-check.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ Compare the `FrontMatter` struct in `src/compile/types.rs` against the documente
7575
Scan template files for markers:
7676

7777
```bash
78-
grep -oP '\{\{[^}]+\}\}' templates/base.yml
79-
grep -oP '\{\{[^}]+\}\}' templates/1es-base.yml
78+
grep -oP '\{\{[^}]+\}\}' src/data/base.yml
79+
grep -oP '\{\{[^}]+\}\}' src/data/1es-base.yml
8080
```
8181

8282
Compare against documented markers in `AGENTS.md`. Check for:

.github/workflows/red-team-security.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Use a **round-robin approach** across these categories. Pick up where the last r
4848

4949
### Category A: Input Sanitization & Injection
5050

51-
Audit `src/sanitize.rs`, `src/compile/types.rs`, `src/compile/common.rs`, and `src/compile/standalone.rs` for:
51+
Audit `src/sanitize.rs`, `src/compile/types.rs`, `src/compile/common.rs`, `src/compile/standalone.rs`, and `src/compile/onees.rs` for:
5252

5353
- **Template injection**: Can a malicious `name`, `description`, or other front matter field inject ADO template expressions (dollar-double-brace syntax) into generated YAML that Azure DevOps evaluates?
5454
- **YAML deserialization**: Can crafted front matter trigger unexpected serde_yaml behavior (anchors, aliases, merge keys, billion-laughs)?
@@ -61,8 +61,9 @@ Focus files:
6161
cat src/sanitize.rs
6262
cat src/compile/common.rs
6363
cat src/compile/standalone.rs
64-
grep -n 'format!' src/compile/standalone.rs | head -40
65-
grep -n 'replace\|replace_with_indent' src/compile/standalone.rs
64+
cat src/compile/onees.rs
65+
grep -n 'format!' src/compile/standalone.rs src/compile/onees.rs | head -40
66+
grep -n 'replace\|replace_with_indent' src/compile/standalone.rs src/compile/onees.rs
6667
```
6768

6869
### Category B: Path Traversal & File System
@@ -101,7 +102,7 @@ grep -rn 'allow\|block\|domain\|host' src/compile/common.rs | head -30
101102

102103
### Category D: Credential & Secret Exposure
103104

104-
Audit `src/compile/standalone.rs`, `src/compile/common.rs`, and `templates/base.yml` for:
105+
Audit `src/compile/standalone.rs`, `src/compile/onees.rs`, `src/compile/common.rs`, `src/data/base.yml`, and `src/data/1es-base.yml` for:
105106

106107
- **Token leakage**: Are ADO tokens (`SC_READ_TOKEN`, `SC_WRITE_TOKEN`, `SYSTEM_ACCESSTOKEN`) ever logged, printed, or embedded in non-secret pipeline variables?
107108
- **MCP env passthrough**: Can the `env:` field in MCP configs leak host environment variables that shouldn't be accessible inside the AWF sandbox?
@@ -111,8 +112,9 @@ Audit `src/compile/standalone.rs`, `src/compile/common.rs`, and `templates/base.
111112
Focus files:
112113
```bash
113114
grep -rn 'SECRET\|TOKEN\|API_KEY\|secret\|password' src/compile/
114-
grep -rn 'SC_READ_TOKEN\|SC_WRITE_TOKEN' src/compile/ templates/
115-
cat templates/base.yml | grep -A2 -B2 'TOKEN\|SECRET\|env:'
115+
grep -rn 'SC_READ_TOKEN\|SC_WRITE_TOKEN' src/compile/ src/data/
116+
cat src/data/base.yml | grep -A2 -B2 'TOKEN\|SECRET\|env:'
117+
cat src/data/1es-base.yml | grep -A2 -B2 'TOKEN\|SECRET\|env:'
116118
```
117119

118120
### Category E: Logic & Authorization Flaws
@@ -135,7 +137,7 @@ grep -rn 'allowed_repos\|repository' src/tools/create_pr.rs
135137

136138
### Category F: Supply Chain & Dependency Integrity
137139

138-
Audit `src/compile/common.rs`, `Cargo.toml`, and `templates/base.yml` for:
140+
Audit `src/compile/common.rs`, `Cargo.toml`, `src/data/base.yml`, and `src/data/1es-base.yml` for:
139141

140142
- **Binary integrity**: Are the `ado-aw`, AWF, and MCPG binaries downloaded with proper checksum verification? Can the checksums file itself be tampered with?
141143
- **Docker image pinning**: Is the MCPG Docker image pinned by digest, or only by tag? Tag-only pinning allows image replacement attacks.
@@ -146,7 +148,7 @@ Focus files:
146148
```bash
147149
cat Cargo.toml
148150
grep -n 'VERSION\|version\|checksum\|sha256\|digest' src/compile/common.rs
149-
grep -n 'docker\|image\|tag\|digest' src/compile/common.rs src/compile/standalone.rs
151+
grep -n 'docker\|image\|tag\|digest' src/compile/common.rs src/compile/standalone.rs src/compile/onees.rs
150152
```
151153

152154
## Step 3: Deep Dive

.github/workflows/rust-pr-reviewer.lock.yml

Lines changed: 11 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/rust-pr-reviewer.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ on:
77
paths:
88
- "src/**"
99
- "tests/**"
10-
- "templates/**"
1110
- "Cargo.toml"
1211
- "Cargo.lock"
1312
description: Reviews Rust code changes for quality, error handling, security, and project conventions

.github/workflows/rust-tests.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ on:
55
paths:
66
- "src/**"
77
- "tests/**"
8-
- "templates/**"
98
- "Cargo.toml"
109
- "Cargo.lock"
1110

AGENTS.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,15 @@ Alongside the correctly generated pipeline yaml, an agent file is generated from
6868
│ ├── runtimes/ # Runtime environment implementations
6969
│ │ ├── mod.rs # Module entry point
7070
│ │ └── lean.rs # Lean 4 theorem prover runtime
71+
│ ├── data/
72+
│ │ ├── base.yml # Base pipeline template for standalone
73+
│ │ ├── 1es-base.yml # Base pipeline template for 1ES target
74+
│ │ ├── ecosystem_domains.json # Network allowlists per ecosystem
75+
│ │ ├── init-agent.md # Dispatcher agent template for `init` command
76+
│ │ └── threat-analysis.md # Threat detection analysis prompt template
7177
│ └── tools/ # First-class tool implementations (compiler auto-configures)
7278
│ ├── mod.rs
7379
│ └── cache_memory.rs
74-
├── templates/
75-
│ ├── base.yml # Base pipeline template for standalone
76-
│ ├── 1es-base.yml # Base pipeline template for 1ES target
77-
│ ├── init-agent.md # Dispatcher agent template for `init` command
78-
│ └── threat-analysis.md # Threat detection analysis prompt template
7980
├── examples/ # Example agent definitions
8081
├── tests/ # Integration tests and fixtures
8182
├── Cargo.toml # Rust dependencies
@@ -540,8 +541,8 @@ When using `target: 1es`, the pipeline will extend `1es/1ES.Unofficial.PipelineT
540541

541542
The compiler transforms the input into valid Azure DevOps pipeline YAML based on the target platform:
542543

543-
- **Standalone**: Uses `templates/base.yml`
544-
- **1ES**: Uses `templates/1es-base.yml`
544+
- **Standalone**: Uses `src/data/base.yml`
545+
- **1ES**: Uses `src/data/1es-base.yml`
545546

546547
Explicit markings are embedded in these templates that the compiler is allowed to replace e.g. `{{ copilot_params }}` denotes parameters which are passed to the copilot command line tool. The compiler should not replace sections denoted by `${{ some content }}`. What follows is a mapping of markings to responsibilities (primarily for the standalone template).
547548

@@ -831,7 +832,7 @@ Example output:
831832

832833
## {{ threat_analysis_prompt }}
833834

834-
Should be replaced with the embedded threat detection analysis prompt from `templates/threat-analysis.md`. This prompt template includes markers for `{{ source_path }}`, `{{ agent_name }}`, `{{ agent_description }}`, and `{{ working_directory }}` which are replaced during compilation.
835+
Should be replaced with the embedded threat detection analysis prompt from `src/data/threat-analysis.md`. This prompt template includes markers for `{{ source_path }}`, `{{ agent_name }}`, `{{ agent_description }}`, and `{{ working_directory }}` which are replaced during compilation.
835836

836837
The threat analysis prompt instructs the security analysis agent to check for:
837838
- Prompt injection attempts

src/compile/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2036,7 +2036,7 @@ pub async fn compile_shared(
20362036
validate_resolve_pr_thread_statuses(front_matter)?;
20372037

20382038
// 11. Threat analysis prompt
2039-
let threat_analysis_prompt = include_str!("../../templates/threat-analysis.md");
2039+
let threat_analysis_prompt = include_str!("../data/threat-analysis.md");
20402040
let template = replace_with_indent(
20412041
&config.template,
20422042
"{{ threat_analysis_prompt }}",

src/compile/onees.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ impl Compiler for OneESCompiler {
6363
let teardown_job = generate_teardown_job(&front_matter.teardown, &front_matter.name);
6464

6565
let config = CompileConfig {
66-
template: include_str!("../../templates/1es-base.yml").to_string(),
66+
template: include_str!("../data/1es-base.yml").to_string(),
6767
extra_replacements: vec![
6868
("{{ firewall_version }}".into(), AWF_VERSION.into()),
6969
("{{ mcpg_version }}".into(), MCPG_VERSION.into()),

src/compile/standalone.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ impl Compiler for StandaloneCompiler {
5858
let mcpg_docker_env = generate_mcpg_docker_env(front_matter);
5959

6060
let config = CompileConfig {
61-
template: include_str!("../../templates/base.yml").to_string(),
61+
template: include_str!("../data/base.yml").to_string(),
6262
extra_replacements: vec![
6363
("{{ firewall_version }}".into(), AWF_VERSION.into()),
6464
("{{ mcpg_version }}".into(), MCPG_VERSION.into()),

0 commit comments

Comments
 (0)