Skip to content
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

Added CodeQL and Bandit security checks as GitHub Actions #3625

Merged
merged 9 commits into from
Apr 7, 2021

Conversation

mstfbl
Copy link
Contributor

@mstfbl mstfbl commented Mar 31, 2021

This PR adds the CodeQL and Bandit Security checks in the form of GitHub Action Workflows, where the two workflows run with each opened PR to the master branch.

For CodeQL, the task will upload CodeQL results under the "Security" GitHub repo tab and in the "Code scanning results" section.

For Bandit, the task will pass if no high-severity issues have been found in the repo (outside of the ./third-party submodules directory).

@mstfbl
Copy link
Contributor Author

mstfbl commented Mar 31, 2021

I see that the ci/circleci: circleci_consistency build test is failing. Per the given instructions, I ran python .circleci/regenerate.py, however I'm only seeing these probably wrong changes occur:

In `.circleci/config.yml:

workflows:
  build:
    jobs:
      - circleci_consistency
      - binary_linux_wheel:
          conda_docker_image: pytorch/conda-builder:cpu
          cu_version: cpu
          name: binary_linux_wheel_py3.6_cpu
          python_version: '3.6'
          wheel_docker_image: pytorch/manylinux-cuda102
      - binary_linux_wheel:
          conda_docker_image: pytorch/conda-builder:cuda101
          cu_version: cu101
          name: binary_linux_wheel_py3.6_cu101
          python_version: '3.6'

Whereas before it was:

workflows:
  build:
    jobs:
      - circleci_consistency
      - binary_linux_wheel:
          conda_docker_image: pytorch/conda-builder:cpu
          cu_version: cpu
          name: binary_linux_wheel_py3.6_cpu
          python_version: '3.6'
          wheel_docker_image: pytorch/manylinux-cuda102
      - binary_linux_wheel:
          conda_docker_image: pytorch/conda-builder:cuda101
          cu_version: cu101
          name: binary_linux_wheel_py3.6_cu101
          python_version: '3.6'

What is the correct fix for this?

Edit: This issues has been fixed with select_autoescape(enabled_extensions=('html', 'xml')).

@NicolasHug
Copy link
Member

I think these changes occur because you changed autoescape=False to True. Was this intended?

@mthrok mthrok requested review from seemethere and malfet April 1, 2021 13:45
Copy link
Member

@fmassa fmassa left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

I'm leaving this to @malfet and @seemethere to decide if we should move forward with this change, but if we do I'd rather have this as an optional dependency.

torchvision/datasets/voc.py Outdated Show resolved Hide resolved
@mstfbl mstfbl requested a review from fmassa April 1, 2021 21:55
@mstfbl
Copy link
Contributor Author

mstfbl commented Apr 1, 2021

Hi @NicolasHug , yes this was intentional. It has now been fixed with select_autoescape(enabled_extensions=('html', 'xml')).

Copy link
Contributor

@malfet malfet left a comment

Choose a reason for hiding this comment

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

LGTM, but please move defusedxml import to the regular import block

torchvision/datasets/voc.py Outdated Show resolved Hide resolved
torchvision/datasets/voc.py Outdated Show resolved Hide resolved
@mstfbl
Copy link
Contributor Author

mstfbl commented Apr 5, 2021

I have removed the Bandit-specific changes from this PR. I've opened #3635 for the autoescape fix and and #3636 for the defusedxml addition.

Copy link
Member

@fmassa fmassa left a comment

Choose a reason for hiding this comment

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

I'm merging this to unblock, but for a follow-up PR could you please update the workflow to use PyTorch nightly instead?

Comment on lines +34 to +35
python -m pip install torch==1.8.1+cpu -f https://download.pytorch.org/whl/torch_stable.html
sudo ln -s /usr/bin/ninja /usr/bin/ninja-build
Copy link
Member

@fmassa fmassa Apr 7, 2021

Choose a reason for hiding this comment

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

(Can be done in a follow-up PR): torchvision from master uses PyTorch nightly, so it would be better to change this to instead install PyTorch from a nightly release

@fmassa fmassa merged commit 9e5edbd into pytorch:master Apr 7, 2021
facebook-github-bot pushed a commit that referenced this pull request Apr 13, 2021
…3625)

Summary:
* Added CodeQL and Bandit security checks as GitHub Actions

* Nit fix on defusedxml.ElementTree

* Remove defusedxml as hard requirement

* Changed diffusedxml/xml importing

* Fix compilation

* Removed Bandit specific changes

Reviewed By: NicolasHug

Differential Revision: D27706940

fbshipit-source-id: c6a9d46d814aabd38e2b2d609d495427c5f2d591

Co-authored-by: Nikita Shulga <nikita.shulga@gmail.com>
Co-authored-by: Nicolas Hug <nicolashug@fb.com>
Co-authored-by: Francisco Massa <fvsmassa@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants