Skip to content

Update powershell_invokewebrequest_downloading_bat.toml #14

Update powershell_invokewebrequest_downloading_bat.toml

Update powershell_invokewebrequest_downloading_bat.toml #14

Workflow file for this run

name: Metrics
# Author = Jamal Uddin Shaikh
on:
push:
paths:
- 'detections/**/*.toml' # Run when any TOML file is added/changed
branches:
- main # or master, depending on your default branch
workflow_dispatch: # Allow manual trigger for testing
schedule:
- cron: "0 0 * * FRI" # Run Every Friday at Mid-night
jobs:
Metrics:
runs-on: ubuntu-latest
permissions:
contents: write # Allow workflow to commit changes
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for proper git operations
token: ${{ secrets.REPORT_METRICS_KEY }}
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.14.3'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install python-dateutil # For toml_to_md.py
- name: Show changed files
run: |
echo "Files changed in this push:"
git diff --name-only ${{ github.event.before }} ${{ github.sha }} || echo "No files changed or first commit"
echo "Looking for TOML files in detections folder..."
- name: Create metrics directory if it doesn't exist
run: mkdir -p metrics development
- name: Run CSV Generator (toml_to_csv.py)
run: |
echo "📊 Generating All_Rules_Created.csv..."
python development/toml_to_csv.py
continue-on-error: false
- name: Run Markdown Report Generator (toml_to_report.py)
run: |
echo "📝 Generating Detections_Report.md..."
python development/toml_to_report.py
continue-on-error: false
- name: Run MITRE Navigator Generator (toml_to_navigator.py)
run: |
echo "🗺️ Generating navigator.json..."
python development/toml_to_navigator.py
continue-on-error: false
- name: Configure Git
run: |
git config --global user.name 'Jamal Uddin Shaikh'
git config --global user.email 'jamal@gmail.com'
- name: Check for changes
id: git-check
run: |
# Add all files in metrics and development folders
git add metrics/ development/
# Check if there are any changes staged
if git diff --staged --quiet; then
echo "No changes to commit"
echo "has_changes=false" >> $GITHUB_OUTPUT
else
echo "Changes detected"
echo "has_changes=true" >> $GITHUB_OUTPUT
echo "Files that will be committed:"
git diff --staged --name-only
fi
- name: Commit and push if changes
if: steps.git-check.outputs.has_changes == 'true'
run: |
git commit -m "🔄 Auto-update metrics from TOML changes [skip ci]"
git push
- name: Summary
if: always() # Always run this step
run: |
if [[ "${{ steps.git-check.outputs.has_changes }}" == "true" ]]; then
echo "✅ Metrics updated and committed successfully!"
else
echo "✅ No changes needed - metrics are already up to date!"
fi
echo "📁 Check the metrics folder for:"
echo " - All_Rules_Created.csv"
echo " - Detections_Report.md"
echo " - Navigator.json"