Skip to content

Commit 7196e72

Browse files
committed
Docstring and test fix
1 parent 9aa684b commit 7196e72

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

detection_rules/rule.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,6 +1132,8 @@ def to_api_format(self, include_version: bool = True) -> dict:
11321132

11331133

11341134
def get_hashable_content(self, include_version: bool = False, include_integrations: bool = False) -> dict:
1135+
"""Returns the rule content to be used for calculating the hash value for the rule"""
1136+
11351137
# get the API dict without the version by default, otherwise it'll always be dirty.
11361138
hashable_dict = self.to_api_format(include_version=include_version)
11371139

@@ -1143,6 +1145,7 @@ def get_hashable_content(self, include_version: bool = False, include_integratio
11431145

11441146
@cached
11451147
def get_hash(self, include_version : bool = False, include_integrations: bool = False) -> str:
1148+
"""Returns a sha256 hash of the rule contents"""
11461149
hashable_contents = self.get_hashable_content(
11471150
include_version=include_version,
11481151
include_integrations=include_integrations,

tests/test_packages.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def get_rule_contents():
4343
version_info = {
4444
rule.id: {
4545
'rule_name': rule.name,
46-
'sha256': rule.contents.sha256(),
46+
'sha256': rule.contents.get_hash(),
4747
'version': version
4848
} for rule in rules
4949
}
@@ -76,7 +76,7 @@ def test_rule_versioning(self):
7676
# test that no rules have versions defined
7777
for rule in rules:
7878
self.assertGreaterEqual(rule.contents.autobumped_version, 1, '{} - {}: version is not being set in package')
79-
original_hashes.append(rule.contents.sha256())
79+
original_hashes.append(rule.contents.get_hash())
8080

8181
package = Package(rules, 'test-package')
8282

@@ -87,7 +87,7 @@ def test_rule_versioning(self):
8787

8888
# test that rules validate with version
8989
for rule in package.rules:
90-
post_bump_hashes.append(rule.contents.sha256())
90+
post_bump_hashes.append(rule.contents.get_hash())
9191

9292
# test that no hashes changed as a result of the version bumps
9393
self.assertListEqual(original_hashes, post_bump_hashes, 'Version bumping modified the hash of a rule')

0 commit comments

Comments
 (0)