From 6d0a9e7719298d76285f646a08e96dc005c4add5 Mon Sep 17 00:00:00 2001 From: Ross Wolf <31489089+rw-access@users.noreply.github.com> Date: Thu, 9 Jul 2020 16:49:27 -0600 Subject: [PATCH 1/2] Generate linted .ts in package --- NOTICE.txt | 10 +++++----- detection_rules/packaging.py | 5 +++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/NOTICE.txt b/NOTICE.txt index aae76f05ca0..7f8bb783553 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -5,11 +5,11 @@ Copyright 2020 Elasticsearch B.V. This product bundles rules based on https://github.com/BlueTeamLabs/sentinel-attack which is available under a "MIT" license. The files based on this license are: -- defense_evasion_via_filter_manager.toml -- discovery_process_discovery_via_tasklist_command.toml -- persistence_priv_escalation_via_accessibility_features.toml -- persistence_via_application_shimming.toml -- defense_evasion_execution_via_trusted_developer_utilities.toml +- defense_evasion_via_filter_manager +- discovery_process_discovery_via_tasklist_command +- persistence_priv_escalation_via_accessibility_features +- persistence_via_application_shimming +- defense_evasion_execution_via_trusted_developer_utilities MIT License diff --git a/detection_rules/packaging.py b/detection_rules/packaging.py index d7b622d0b9e..933175bbe4b 100644 --- a/detection_rules/packaging.py +++ b/detection_rules/packaging.py @@ -131,7 +131,7 @@ def _package_notice_file(save_dir): notice_txt = f.read() with open(os.path.join(save_dir, 'notice.ts'), 'wt') as f: - commented_notice = [' * ' + line for line in notice_txt.splitlines()] + commented_notice = [(' * ' + line).rstrip() for line in notice_txt.splitlines()] lines = ['/* eslint-disable @kbn/eslint/require-license-header */', '', '/* @notice'] lines = lines + commented_notice + [' */', ''] f.write('\n'.join(lines)) @@ -150,7 +150,7 @@ def _package_index_file(self, save_dir): const_exports = ['export const rawRules = ['] const_exports.extend(f" rule{i}," for i, _ in enumerate(sorted_rules, 1)) const_exports.append("];") - const_exports.append(" ") + const_exports.append("") index_ts = [JS_LICENSE, ""] index_ts.extend(comments) @@ -158,6 +158,7 @@ def _package_index_file(self, save_dir): index_ts.extend(rule_imports) index_ts.append("") index_ts.extend(const_exports) + with open(os.path.join(save_dir, 'index.ts'), 'wt') as f: f.write('\n'.join(index_ts)) From 48db253ef82b656fae0ffcf9f09844c85fe7a983 Mon Sep 17 00:00:00 2001 From: Ross Wolf <31489089+rw-access@users.noreply.github.com> Date: Thu, 9 Jul 2020 16:55:09 -0600 Subject: [PATCH 2/2] (Lin|ni)t changes Co-authored-by: Justin Ibarra --- detection_rules/packaging.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/detection_rules/packaging.py b/detection_rules/packaging.py index 933175bbe4b..414e75de8d6 100644 --- a/detection_rules/packaging.py +++ b/detection_rules/packaging.py @@ -131,7 +131,7 @@ def _package_notice_file(save_dir): notice_txt = f.read() with open(os.path.join(save_dir, 'notice.ts'), 'wt') as f: - commented_notice = [(' * ' + line).rstrip() for line in notice_txt.splitlines()] + commented_notice = [f' * {line}'.rstrip() for line in notice_txt.splitlines()] lines = ['/* eslint-disable @kbn/eslint/require-license-header */', '', '/* @notice'] lines = lines + commented_notice + [' */', ''] f.write('\n'.join(lines))