|
1 | 1 | import click |
2 | 2 | import sys |
| 3 | +import time |
3 | 4 | from veracode.application import Application |
4 | 5 | from veracode.sandbox import Sandbox |
| 6 | +from veracode.build import Build |
5 | 7 | from veracode.utils.report import display |
6 | 8 |
|
7 | 9 | @click.group() |
@@ -70,6 +72,35 @@ def update(name, rename=None, criticality=None): |
70 | 72 |
|
71 | 73 |
|
72 | 74 | @app.command() |
73 | | -def scan(): |
74 | | - click.echo('scan') |
| 75 | +@click.option('--app', '-a', required=True, |
| 76 | + help='Name of the application.') |
| 77 | +@click.option('--files', '-f', required=True, |
| 78 | + help='Files to upload.') |
| 79 | +@click.option('--name', '-n', |
| 80 | + help='Name of the new scan.') |
| 81 | +@click.option('--sandbox', '-s', |
| 82 | + help='Name of the sandbox.') |
| 83 | +@click.option('--timeout', '-t', type=int, |
| 84 | + help='Timeout in minutes for scan results.') |
| 85 | +def scan(app, files, name=None, sandbox=None, timeout=None): |
| 86 | + app = Application(app) |
| 87 | + app.sandbox = sandbox |
| 88 | + build = Build() |
| 89 | + build.name = name |
| 90 | + app.build = build |
| 91 | + app.build.upload([files]) |
| 92 | + app.build.scan() |
| 93 | + |
| 94 | + if timeout: |
| 95 | + for w in range(timeout): |
| 96 | + time.sleep(60) |
| 97 | + if app.build.analysis.status == 'Results Ready': |
| 98 | + click.echo('Veracode Security Policy: {}'.format( |
| 99 | + app.build.report.policy_rules_status)) |
| 100 | + return 'Pass' in app.build.report.policy_rules_status |
| 101 | + app = Application(app.name, sandbox=sandbox, build=name) |
| 102 | + click.echo('Scan status: {}'.format(app.build.analysis.status)) |
| 103 | + click.echo('Scan timeout after {} minutes'.format(timeout)) |
| 104 | + return False |
| 105 | + |
75 | 106 |
|
0 commit comments