Skip to content

Commit 10a5568

Browse files
brokensound77github-actions[bot]
authored andcommitted
Add test command to verify version collisions do not occur (#2272)
* Add test command to verify version collisions do not occur * add max_allowable_version to schema and lock flow * add max_allowable_version to all entries in version.lock * add test-version-lock command * use min supported stack if > locked min stack * share lock conversion code with rule and lock to fix M.m bug (cherry picked from commit 2ee5a18)
1 parent cca9f18 commit 10a5568

File tree

5 files changed

+10010
-9231
lines changed

5 files changed

+10010
-9231
lines changed

detection_rules/devtools.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,32 @@ def license_check(ctx, ignore_directory):
637637
ctx.exit(int(failed))
638638

639639

640+
@dev_group.command('test-version-lock')
641+
@click.argument('branches', nargs=-1, required=True)
642+
@click.option('--remote', '-r', default='origin', help='Override the remote from "origin"')
643+
def test_version_lock(branches: tuple, remote: str):
644+
"""Simulate the incremental step in the version locking to find version change violations."""
645+
git = utils.make_git('-C', '.')
646+
current_branch = git('rev-parse', '--abbrev-ref', 'HEAD')
647+
648+
try:
649+
click.echo(f'iterating lock process for branches: {branches}')
650+
for branch in branches:
651+
click.echo(branch)
652+
git('checkout', f'{remote}/{branch}')
653+
subprocess.check_call(['python', '-m', 'detection_rules', 'dev', 'build-release', '-u'])
654+
655+
finally:
656+
diff = git('--no-pager', 'diff', get_etc_path('version.lock.json'))
657+
outfile = Path(get_path()).joinpath('lock-diff.txt')
658+
outfile.write_text(diff)
659+
click.echo(f'diff saved to {outfile}')
660+
661+
click.echo('reverting changes in version.lock')
662+
git('checkout', '-f')
663+
git('checkout', current_branch)
664+
665+
640666
@dev_group.command('package-stats')
641667
@click.option('--token', '-t', help='GitHub token to search API authenticated (may exceed threshold without auth)')
642668
@click.option('--threads', default=50, help='Number of threads to download rules from GitHub')

0 commit comments

Comments
 (0)