Skip to content

Commit

Permalink
Merge pull request #94 from center-for-threat-informed-defense/AF-118…
Browse files Browse the repository at this point in the history
…-publish-jsons-cli

Add a command line tool for publishing .afb files to .json
  • Loading branch information
mikecarenzo committed Aug 7, 2023
2 parents 733996d + 7325579 commit 3ea23b0
Show file tree
Hide file tree
Showing 41 changed files with 312 additions and 17,858 deletions.
21 changes: 10 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18'
node-version: '19'
- name: Install dependencies
working-directory: ./src/attack_flow_builder/
run: npm ci
Expand All @@ -28,13 +28,6 @@ jobs:
# Workaround for node.js bug: https://github.com/webpack/webpack/issues/14532
NODE_OPTIONS: "--openssl-legacy-provider"
run: npm run build
# TODO: uncomment when we add autocomplete to the builder:
# - name: Fetch ATT&CK Data
# working-directory: ./src/attack_flow_builder/
# run: npm run fetch-attack
# - name: Build ATT&CK Index
# working-directory: ./src/attack_flow_builder/
# run: npm run build-index
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
Expand All @@ -52,17 +45,20 @@ jobs:
python-version: '3.8'
- uses: actions/setup-node@v3
with:
node-version: '18'
node-version: '19'
- name: Update APT
run: sudo apt update
- name: Install dependencies
- name: Install APT dependencies
run: sudo apt install graphviz
- name: Install Poetry
run: curl -sSL https://install.python-poetry.org/ | python -
- name: Add Poetry to PATH
run: echo "$HOME/.poetry/bin" >> $GITHUB_PATH
- name: Install dependencies
- name: Install Python dependencies
run: poetry install
- name: Install Node dependencies
working-directory: ./src/attack_flow_builder/
run: npm ci
- name: Install Mermaid
run: npm install -g @mermaid-js/mermaid-cli
- name: Create client directory
Expand All @@ -75,6 +71,9 @@ jobs:
- name: Make Attack Flow schema
run: poetry run make docs-schema
- name: Copy corpus into docs
env:
# Workaround for node.js bug: https://github.com/webpack/webpack/issues/14532
NODE_OPTIONS: "--openssl-legacy-provider"
run: poetry run make docs-examples
- name: Copy matrix-viz code into docs
run: poetry run make docs-matrix
Expand Down
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ docs:
docs-examples:
mkdir -p docs/extra/corpus
cp corpus/*.afb docs/extra/corpus
cd src/attack_flow_builder && env VUE_CLI_SERVICE_CONFIG_PATH="${ROOTDIR}src/attack_flow_builder/vue.cli.config.js" npx vue-cli-service build --target lib --name cli --formats commonjs --no-clean src/cli.ts
node src/attack_flow_builder/dist/cli.common.js --verbose corpus/*.afb
cp corpus/*.json docs/extra/corpus
ls -1 corpus/*.json | sed 's/corpus\/\(.*\)\.json/\1/' | xargs -t -I {} af graphviz "corpus/{}.json" "docs/extra/corpus/{}.dot"
ls -1 docs/extra/corpus/*.dot | xargs -t -I {} dot -Tpng -O -q1 "{}"
Expand Down
1 change: 1 addition & 0 deletions corpus/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.json
Loading

0 comments on commit 3ea23b0

Please sign in to comment.