Skip to content

[FR] Add --force flag to update-lock-versions #3693

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions detection_rules/devtools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Copy link
Contributor

Choose a reason for hiding this comment

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

a nitpick: Tuple typehint is a bit too click-specific here, Sequence would be a better choice, if it is really not a list :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree that Sequence is more appropriate; however, we do not use Sequence in the code elsewhere for type hinting and we do use Tuple[str, ...]. For consistency, I think we should update to Sequence in a different PR where we can modify all of the relevant type hints all at once.

"""Update rule hashes in version.lock.json file without bumping version."""
rules = RuleCollection.default()

Expand All @@ -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
Expand Down