mirror of
https://github.com/placeholder-soft/chroma.git
synced 2026-01-12 08:44:18 +08:00
[SEC]: Bandit Scan (#1113)
## Description of changes *Summarize the changes made by this PR.* - Improvements & Bug fixes - Added bandit scanning for all pushes to repo ## Test plan *How are these changes tested?* Manual testing of the workflow ## Documentation Changes N/A - unless we want to start a separate security section in the main docs repo. --------- Co-authored-by: Hammad Bashir <HammadB@users.noreply.github.com>
This commit is contained in:
7
.github/actions/bandit-scan/Dockerfile
vendored
Normal file
7
.github/actions/bandit-scan/Dockerfile
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
FROM python:3.10-alpine AS base-action
|
||||
|
||||
RUN pip3 install -U setuptools pip bandit
|
||||
|
||||
COPY entrypoint.sh /entrypoint.sh
|
||||
RUN chmod +x /entrypoint.sh
|
||||
ENTRYPOINT ["sh","/entrypoint.sh"]
|
||||
26
.github/actions/bandit-scan/action.yaml
vendored
Normal file
26
.github/actions/bandit-scan/action.yaml
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
name: 'Bandit Scan'
|
||||
description: 'This action performs a security vulnerability scan of python code using bandit library.'
|
||||
inputs:
|
||||
bandit-config:
|
||||
description: 'Bandit configuration file'
|
||||
required: false
|
||||
input-dir:
|
||||
description: 'Directory to scan'
|
||||
required: false
|
||||
default: '.'
|
||||
format:
|
||||
description: 'Output format (txt, csv, json, xml, yaml). Default: json'
|
||||
required: false
|
||||
default: 'json'
|
||||
output-file:
|
||||
description: "The report file to produce. Make sure to align your format with the file extension to avoid confusion."
|
||||
required: false
|
||||
default: "bandit-scan.json"
|
||||
runs:
|
||||
using: 'docker'
|
||||
image: 'Dockerfile'
|
||||
args:
|
||||
- ${{ inputs.format }}
|
||||
- ${{ inputs.bandit-config }}
|
||||
- ${{ inputs.input-dir }}
|
||||
- ${{ inputs.output-file }}
|
||||
13
.github/actions/bandit-scan/entrypoint.sh
vendored
Executable file
13
.github/actions/bandit-scan/entrypoint.sh
vendored
Executable file
@@ -0,0 +1,13 @@
|
||||
#!/bin/bash
|
||||
CFG="-c $2"
|
||||
if [ -z "$1" ]; then
|
||||
echo "No path to scan provided"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$2" ]; then
|
||||
CFG = ""
|
||||
fi
|
||||
|
||||
bandit -f "$1" ${CFG} -r "$3" -o "$4"
|
||||
exit 0 #we want to ignore the exit code of bandit (for now)
|
||||
28
.github/workflows/python-vuln.yaml
vendored
Normal file
28
.github/workflows/python-vuln.yaml
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
name: Python Vulnerability Scan
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- '*'
|
||||
- '*/**'
|
||||
paths:
|
||||
- chromadb/**
|
||||
- clients/python/**
|
||||
workflow_dispatch:
|
||||
jobs:
|
||||
bandit-scan:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- uses: ./.github/actions/bandit-scan/
|
||||
with:
|
||||
input-dir: '.'
|
||||
format: 'json'
|
||||
bandit-config: 'bandit.yaml'
|
||||
output-file: 'bandit-report.json'
|
||||
- name: Upload Bandit Report
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: bandit-artifact
|
||||
path: |
|
||||
bandit-report.json
|
||||
4
bandit.yaml
Normal file
4
bandit.yaml
Normal file
@@ -0,0 +1,4 @@
|
||||
# FILE: bandit.yaml
|
||||
exclude_dirs: [ 'chromadb/test', 'bin', 'build', 'build', '.git', '.venv', 'venv', 'env','.github','examples','clients/js','.vscode' ]
|
||||
tests: [ ]
|
||||
skips: [ ]
|
||||
Reference in New Issue
Block a user