-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Enable bandit #12722
Merged
praveenkuttappan
merged 4 commits into
Azure:master
from
praveenkuttappan:enable_bandit
Jul 27, 2020
Merged
Enable bandit #12722
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
98afcce
Add new step to run Bandit security scan tool
praveenkuttappan bde7371
Revert changes in mypy pylint yaml
praveenkuttappan 08cdbff
Exclude management packages from Bandit scna
praveenkuttappan c4f7a10
Fix package exclusion logic
praveenkuttappan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
parameters: | ||
BuildTargetingString: 'azure-*' | ||
ServiceDirectory: '' | ||
TestMarkArgument: '' | ||
EnvVars: {} | ||
|
||
steps: | ||
- task: PythonScript@0 | ||
displayName: 'Run Bandit' | ||
inputs: | ||
scriptPath: 'scripts/devops_tasks/setup_execute_tests.py' | ||
arguments: >- | ||
"${{ parameters.BuildTargetingString }}" | ||
--mark_arg="${{ parameters.TestMarkArgument }}" | ||
--service="${{ parameters.ServiceDirectory }}" | ||
--toxenv="bandit" | ||
--disablecov | ||
--filter-type="Bandit" | ||
env: ${{ parameters.EnvVars }} | ||
condition: and(succeededOrFailed(), ne(variables['Skip.Bandit'],'true')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/usr/bin/env python | ||
|
||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
# This script is used to execute bandit within a tox environment. Depending on which package is being executed against, | ||
# a failure may be suppressed. | ||
|
||
from subprocess import check_call, CalledProcessError | ||
import argparse | ||
import os | ||
import logging | ||
import sys | ||
|
||
|
||
logging.getLogger().setLevel(logging.INFO) | ||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser(description="Run bandit against target folder.") | ||
|
||
parser.add_argument( | ||
"-t", | ||
"--target", | ||
dest="target_package", | ||
help="The target package directory on disk. The target module passed to bandit will be <target_package>/azure.", | ||
required=True, | ||
) | ||
|
||
args = parser.parse_args() | ||
|
||
package_name = os.path.basename(os.path.abspath(args.target_package)) | ||
try: | ||
check_call( | ||
[ | ||
sys.executable, | ||
"-m", | ||
"bandit", | ||
"-r", | ||
os.path.join(args.target_package, "azure"), | ||
"-ll", | ||
] | ||
) | ||
except CalledProcessError as e: | ||
logging.error("{} exited with error {}".format(package_name, e.returncode)) | ||
exit(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was about to suggest updates to
build-test.yml
but I realize we don't make use of the filter type for it :P