Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Format Checker for MITRE ATT&CK Matrix Report Mappings #1360

Merged
merged 4 commits into from
Sep 25, 2024

Conversation

ben-githubs
Copy link
Contributor

Background

If a rule has a MITRE ATT&CK report mapping with an invalid format, the mapping doesn't resolve properly in the UI. This PR adds some automation to check for misformatted MITRE mappings and alert on them.

See this PR for more details.

This check didn't really fit as part of pat validate or pat test, since it's concerned with the format of the YAML file, so we chose to add it a script that can be run as part of make lint.

Changes

  • added a .scripts directory, with a python script to check the mapping formats
  • automatically run the script when make lint is invoked

Testing

  • Artificially misformatted a MITRE mapping and confirmed the script alerted on it when using make lint, and confirm it didn't raise any false positives when no malformed mappings were present

@ben-githubs ben-githubs requested a review from a team as a code owner September 19, 2024 18:03
Copy link

😱
looks like some things could be wrong with the packs

[INFO][root]: ignoring file dependabot.yml

@ben-githubs
Copy link
Contributor Author

I have one concern with this: adding it to make lint means that some customers that have malformed MITRE tags will have the lint action fail. This might be a blocking issue for some customers. We may decide to add this as a separate lint action for now (just make lint-mitre or something) and instruct customers to run this on their local rules independently, and then make it part of the general lint action in 3 months or whatever. That way customers have time to see what mappings are broken and action on them before we make it a requirement for lint to pass.

Makefile Outdated
@@ -43,6 +43,9 @@ lint-fmt:
@echo Checking python file formatting with the black code style checker
pipenv run black --line-length=100 --check $(dirs)

lint-misc:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not introducing lint-mitre and then introduce lint-misc whenever another "misc" linting is added in the future? And the lint-misc will be running the mitre lint and the newly introduced one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense! In both cases, the MITRE check will run during make lint, so customers won't need to make any changes to their workflows

Removed the mitre check from `make lint` command and added a separate make target, `make lint-mitre`.
@ben-githubs ben-githubs enabled auto-merge (squash) September 24, 2024 19:20
@arielkr256 arielkr256 added enhancement New feature or request github_actions Pull requests that update GitHub Actions code labels Sep 25, 2024
Copy link
Contributor

@arielkr256 arielkr256 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

@ben-githubs ben-githubs merged commit a5190d2 into release Sep 25, 2024
8 checks passed
@ben-githubs ben-githubs deleted the ben/mitre-mapping-format-checker branch September 25, 2024 17:38
@arielkr256 arielkr256 removed the enhancement New feature or request label Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
github_actions Pull requests that update GitHub Actions code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants