Skip to content

Conversation

@jklm264
Copy link

@jklm264 jklm264 commented Dec 30, 2025

Description of the change

This PR updates the _update_rules logic to handle edge cases. It fixes Yara rule pull updates, which currently fail to update when this function is run on a non-git directory.

  • Added a check: If the rules directory does not exist, use git.clone to fetch it.
  • Added error handling: Catches InvalidGitRepositoryError to prevent crashes if the directory exists but is not a git repo.
  • Improved logging for these scenarios.

Applicable issues

N/A

Additional information

Nay

Checklist

  • [] All tests were successful.; couldn't find pip install -r dfvfs_requirements.txt that may have included [No] module named 'coverage'

Jordan Mussman added 4 commits December 30, 2025 11:49
…in cases where RULES path is not a git repo
…in cases where RULES path is not a git repo
- Fixed indentation errors.
- Corrected misleading comments.
- Implemented non-blocking updates: the loop now continues to process other repositories even if one fails.
@Fryyyyy
Copy link
Collaborator

Fryyyyy commented Jan 5, 2026

I'll take a look at the test run failures once I'm back at work

Copy link
Member

@aarontp aarontp left a comment

Choose a reason for hiding this comment

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

Overall LGTM, but some of the indentation needs to be updated.

log.info('Yara rules cloned successfully.')
except git.exc.GitCommandError as e:
log.error('Error cloning Yara rules from {0:s}: {1!s}'.format(repo, e))
update_success = False
Copy link
Member

Choose a reason for hiding this comment

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

Looks like this has incorrect indentation

log.error(
'InvalidGitRepositoryError updating rules in %s: %s', path, str(e),
exc_info=True)
update_success = False
Copy link
Member

Choose a reason for hiding this comment

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

Couple more lines that need indentation fixes here/below too.

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.

3 participants