-
Notifications
You must be signed in to change notification settings - Fork 64
147 lines (132 loc) · 4.77 KB
/
agents-cli.yml
File metadata and controls
147 lines (132 loc) · 4.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
name: Agents CLI - Smoke Tests
on:
push:
branches: [main, develop]
paths:
- 'agents/**'
- '.github/workflows/agents-cli.yml'
pull_request:
branches: [main, develop]
paths:
- 'agents/**'
- '.github/workflows/agents-cli.yml'
defaults:
run:
working-directory: agents
jobs:
typecheck:
name: TypeScript Compilation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20.x'
- run: npm install --registry https://registry.npmjs.org/
- run: npm run typecheck
- run: npm run build
- name: Verify dist output
run: test -f dist/src/cli.js && test -f dist/graphs/detection-pipeline.js
cli-smoke:
name: CLI Smoke Tests (${{ matrix.test }})
needs: typecheck
runs-on: ubuntu-latest
env:
DRY_RUN: 'true'
strategy:
fail-fast: false
matrix:
include:
# -- help flags --
- test: orchestrate --help
cmd: npx tsx src/cli.ts orchestrate --help
expect: input
- test: analyze --help
cmd: npx tsx src/cli.ts analyze --help
expect: technique
- test: validate --help
cmd: npx tsx src/cli.ts validate --help
expect: detection
# -- orchestrate input methods --
- test: orchestrate --input
cmd: npx tsx src/cli.ts orchestrate --type technique --input "T1566.004 Spearphishing Voice"
expect: '"techniques"'
- test: orchestrate --content (alias)
cmd: npx tsx src/cli.ts orchestrate --type technique --content "T1566.004 Spearphishing Voice"
expect: '"techniques"'
- test: orchestrate --file
cmd: bash -c 'echo "T1566.004 Spearphishing Voice" > /tmp/report.md && npx tsx src/cli.ts orchestrate --type threat_report --file /tmp/report.md'
expect: '"techniques"'
# -- orchestrate --type values --
- test: orchestrate --type technique
cmd: npx tsx src/cli.ts orchestrate --type technique --input "T1059.001 PowerShell"
expect: '"input_type": "technique"'
- test: orchestrate --type manual
cmd: npx tsx src/cli.ts orchestrate --type manual --input "PowerShell encoded commands"
expect: '"input_type": "manual"'
- test: orchestrate --type threat_report
cmd: npx tsx src/cli.ts orchestrate --type threat_report --input "Actor uses PsExec T1021.002"
expect: '"input_type": "threat_report"'
# -- dry run runs full pipeline --
- test: dry run hits all 10 nodes
cmd: npx tsx src/cli.ts orchestrate --type technique --input "T1566.004 Spearphishing Voice"
expect: 'PR Stager'
# -- analyze command --
- test: analyze --technique
cmd: npx tsx src/cli.ts analyze --technique T1003.001
expect: Analysis Complete
- test: analyze --input
cmd: npx tsx src/cli.ts analyze --input "T1566.004 Spearphishing Voice"
expect: Analysis Complete
# -- validate command --
- test: validate --technique (dry run)
cmd: npx tsx src/cli.ts validate --technique T1003.001
expect: Validate Mode
# -- status command --
- test: status
cmd: npx tsx src/cli.ts status
expect: Pipeline Status
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20.x'
- run: npm install --registry https://registry.npmjs.org/
- name: '${{ matrix.test }}'
run: |
OUTPUT=$(${{ matrix.cmd }} 2>&1) || true
echo "$OUTPUT"
echo "$OUTPUT" | grep -qF '${{ matrix.expect }}'
cli-error-handling:
name: CLI Error Handling
needs: typecheck
runs-on: ubuntu-latest
env:
DRY_RUN: 'true'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20.x'
- run: npm install --registry https://registry.npmjs.org/
- name: 'orchestrate with no input exits non-zero'
run: |
set +e
npx tsx src/cli.ts orchestrate --type technique 2>&1
EXIT_CODE=$?
set -e
test $EXIT_CODE -ne 0
- name: 'orchestrate with missing file exits non-zero'
run: |
set +e
npx tsx src/cli.ts orchestrate --type threat_report --file ./does-not-exist.md 2>&1
EXIT_CODE=$?
set -e
test $EXIT_CODE -ne 0
- name: 'validate with no args exits non-zero'
run: |
set +e
npx tsx src/cli.ts validate 2>&1
EXIT_CODE=$?
set -e
test $EXIT_CODE -ne 0