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

Lint rule formatting and improved rule dump #401

Merged
merged 7 commits into from
Jan 28, 2021
Merged

Conversation

mr-tz
Copy link
Collaborator

@mr-tz mr-tz commented Jan 26, 2021

  • changes to arrive at the desired yaml rule format
  • capafmt option to only check differences
  • linter updates to ensure right yaml formatting

The changes in mandiant/capa-rules#230 have been performed using the updated capafmt script included here.

closes #313

# only do this for the features section, so the meta description doesn't get reformatted
# assumes features section always exists
features_offset = doc.find("features")
doc = doc[:features_offset] + doc[features_offset:].replace(" description:", " description:")
Copy link
Collaborator

Choose a reason for hiding this comment

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

good catch

scripts/lint.py Outdated
Comment on lines 300 to 304
# fix negative numbers
# - offset: -0x30
# instead of
# - offset: !!int '0x-30'
expected = re.sub(r"!!int '0x-([0-9a-fA-F]+)'", r"-0x\1", expected)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

🤓

@mr-tz mr-tz changed the title check rule format consistency Lint rule formatting and improved rule dump Jan 28, 2021
@mr-tz mr-tz marked this pull request as ready for review January 28, 2021 10:14
@mr-tz mr-tz requested a review from williballenthin January 28, 2021 10:17
@williballenthin williballenthin merged commit 14e65c4 into master Jan 28, 2021
@williballenthin williballenthin deleted the linter-format branch January 28, 2021 16:18
@mr-tz
Copy link
Collaborator Author

mr-tz commented Jan 28, 2021

Thanks, I'll reformat the new rules resulting in the linter fail now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

linter should enforce rule formatting
2 participants