From 707ca32ab15f57f1cd804d93e5e86b108db7ceb8 Mon Sep 17 00:00:00 2001 From: Eric Forte <119343520+eric-forte-elastic@users.noreply.github.com> Date: Fri, 17 May 2024 20:25:08 -0400 Subject: [PATCH] [FR] Add --force flag to update-lock-versions (#3693) * Add --force flag to update-lock-versions * Add type hinting --- detection_rules/devtools.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/detection_rules/devtools.py b/detection_rules/devtools.py index f6277c98b..4349c0c49 100644 --- a/detection_rules/devtools.py +++ b/detection_rules/devtools.py @@ -334,7 +334,8 @@ def prune_staging_area(target_stack_version: str, dry_run: bool, exception_list: @dev_group.command('update-lock-versions') @click.argument('rule-ids', nargs=-1, required=False) -def update_lock_versions(rule_ids): +@click.option('--force', is_flag=True, help='Force update without confirmation') +def update_lock_versions(rule_ids: Tuple[str, ...], force: bool): """Update rule hashes in version.lock.json file without bumping version.""" rules = RuleCollection.default() @@ -343,7 +344,9 @@ def update_lock_versions(rule_ids): else: rules = rules.filter(production_filter) - if not click.confirm(f'Are you sure you want to update hashes for {len(rules)} rules without a version bump?'): + if not force and not click.confirm( + f'Are you sure you want to update hashes for {len(rules)} rules without a version bump?' + ): return # this command may not function as expected anymore due to previous changes eliminating the use of add_new=False