Generate YARA rules from latest Microsoft Defender AV Signature #10811
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Generate YARA rules from latest Microsoft Defender AV Signature | |
on: | |
schedule: | |
- cron: "0,30 * * * *" # every 30 minutes | |
push: | |
branches: | |
- main | |
jobs: | |
update-rules: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install exiftool | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y exiftool | |
- name: Set up python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12' | |
- name: Load cached Poetry installation | |
id: cached-poetry | |
uses: actions/cache@v4 | |
with: | |
path: ~/.local | |
key: poetry-0 | |
- name: Install Poetry | |
if: steps.cached-poetry.outputs.cache-hit != 'true' | |
uses: snok/install-poetry@v1 | |
- name: Install Python package dependencies | |
run: | | |
poetry install | |
- name: Get latest signature version | |
run: | | |
echo "SIG_VERSION=$(poetry run python -m defender2yara --latest_signature_version)" >> $GITHUB_ENV | |
- name: Check if SIG_VERSION is empty and fail if true | |
run: | | |
if [ -z "$SIG_VERSION" ]; then | |
echo "SIG_VERSION is empty, failing the job." | |
exit 1 | |
else | |
echo "SIG_VERSION is not empty, continuing." | |
fi | |
- name: Load cached vdm files | |
id: cached-vdm | |
uses: actions/cache@v4 | |
with: | |
path: ./cache | |
key: vdm-${{ env.SIG_VERSION }} | |
- name: Generate YARA rules | |
if: steps.cached-vdm.outputs.cache-hit != 'true' || (github.event_name == 'push' && github.ref == 'refs/heads/main') | |
run: | | |
poetry run python -m defender2yara --cache ./cache -o ./rules | |
- name: Deploy on yara-rules branch | |
if: steps.cached-vdm.outputs.cache-hit != 'true' || (github.event_name == 'push' && github.ref == 'refs/heads/main') | |
uses: JamesIves/github-pages-deploy-action@v4.6.4 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
branch: yara-rules | |
folder: rules/${{ env.SIG_VERSION }}/ | |
commit-message: ${{ env.SIG_VERSION }} | |
clean: true | |
# single-commit: true |