Skip to content

Commit

Permalink
feat: Add bandit ci pipeline (#1200)
Browse files Browse the repository at this point in the history
* feat: Add bandit ci pipeline

* feat: add useforsecurty false for bandit pipeline

* feat: Add report only for High severity issues
  • Loading branch information
pythonbyte authored Aug 15, 2024
1 parent 92a77e5 commit d0707fa
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 3 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/security-checker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Security Checker

on: [pull_request]

jobs:
security-check:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11.9"

- name: Install dependencies
run: pip install bandit

- name: Run Bandit
run: bandit -c pyproject.toml -r src/ -lll

3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ ignore_missing_imports = true
disable_error_code = 'import-untyped'
exclude = ["cli/templates"]

[tool.bandit]
exclude_dirs = ["src/crewai/cli/templates"]

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
2 changes: 1 addition & 1 deletion src/crewai/agents/agent_builder/base_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def set_private_attrs(self):
@property
def key(self):
source = [self.role, self.goal, self.backstory]
return md5("|".join(source).encode()).hexdigest()
return md5("|".join(source).encode(), usedforsecurity=False).hexdigest()

@abstractmethod
def execute_task(
Expand Down
2 changes: 1 addition & 1 deletion src/crewai/crew.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ def key(self) -> str:
source = [agent.key for agent in self.agents] + [
task.key for task in self.tasks
]
return md5("|".join(source).encode()).hexdigest()
return md5("|".join(source).encode(), usedforsecurity=False).hexdigest()

def _setup_from_config(self):
assert self.config is not None, "Config should not be None."
Expand Down
2 changes: 1 addition & 1 deletion src/crewai/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def key(self) -> str:
expected_output = self._original_expected_output or self.expected_output
source = [description, expected_output]

return md5("|".join(source).encode()).hexdigest()
return md5("|".join(source).encode(), usedforsecurity=False).hexdigest()

def execute_async(
self,
Expand Down

0 comments on commit d0707fa

Please sign in to comment.