Skip to content

Commit 07be6b7

Browse files
authored
Change the asset .type field (#1075)
1 parent 1e6e49a commit 07be6b7

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

detection_rules/packaging.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -498,8 +498,8 @@ def _generate_registry_package(self, save_dir):
498498
# shutil.copyfile(CHANGELOG_FILE, str(rules_dir.joinpath('CHANGELOG.json')))
499499

500500
for rule in self.rules:
501-
with Path(rules_dir.joinpath(f'rule-{rule.id}.json')).open("w", encoding="utf-8") as f:
502-
json.dump(rule.get_asset(), f, indent=2, sort_keys=True)
501+
asset_path = rules_dir / f'rule-{rule.id}.json'
502+
asset_path.write_text(json.dumps(rule.get_asset(), indent=4, sort_keys=True), encoding="utf-8")
503503

504504
readme_text = ('# Detection rules\n\n'
505505
'The detection rules package stores all the security rules '

detection_rules/rule.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ def name(self):
434434

435435
def get_asset(self) -> dict:
436436
"""Generate the relevant fleet compatible asset."""
437-
return {"id": self.id, "attributes": self.contents.to_api_format(), "type": definitions.ASSET_TYPE}
437+
return {"id": self.id, "attributes": self.contents.to_api_format(), "type": definitions.SAVED_OBJECT_TYPE}
438438

439439
def save_toml(self):
440440
converted = self.contents.to_dict()

detection_rules/schemas/definitions.py

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from marshmallow_dataclass import NewType
1212

1313
ASSET_TYPE = "security_rule"
14+
SAVED_OBJECT_TYPE = "security-rule"
1415

1516
DATE_PATTERN = r'\d{4}/\d{2}/\d{2}'
1617
MATURITY_LEVELS = ['development', 'experimental', 'beta', 'production', 'deprecated']

etc/packages.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ package:
2222
# min_version: 1
2323
# max_version: 5
2424

25-
# Integrations registry
25+
# elastic/integrations
2626
registry_data:
2727
# integration package schema version
2828
format_version: "1.0.0"
2929
conditions:
3030
kibana_version: "^7.13.0"
3131
# this determines the version for the package-storage generated artifact
32-
version: "0.0.1-dev.1"
32+
version: "0.0.1-dev.3"

0 commit comments

Comments
 (0)