Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
Dockerfile
LICENSE
README.md
setup.cfg
tests/
52 changes: 52 additions & 0 deletions .github/workflows/dogfood.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# This workflow tests the workbench-agent by scanning its own repository.
## This workflow runs manually on whatever branch its pointed at.
name: Scan a Branch!
on: workflow_dispatch

jobs:
fossid_scan:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

# Zipping the code uploads a single file for Workbench to extract.
- name: ZIP up the code
run: |
zip -r $GITHUB_WORKSPACE/code.zip . -x \
'*.tmp' '*.temp' '*.bak' \
'*.cache' '*.db' '*.idx' \
'*.log' '*.txt' '*.event' \
'*.sample' '*.demo' '*.example' \
'*.sql' '*.hprof' '*.dmp' \
'.gitignore' '.dockerignore' \
'.git/*' '.github/*'

# Since we're running with Python, install the dependencies.
# This is not needed when running the container image.
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Install Workbench Agent Dependencies
run: pip install -e .

# We omit License Extraction to speed up the scan process.
# Built-In Env Vars map Branches to Scans in Workbench for this repo's Project.
# Additionally, Delta Scan reduces scan time by only scanning new files.
- name: Scan the ZIP
run: |
python workbench-agent.py \
--api_url ${{ secrets.WORKBENCH_URL }} \
--api_user ${{ secrets.WORKBENCH_USER }} \
--api_token ${{ secrets.WORKBENCH_TOKEN }} \
--project_code $GITHUB_REPOSITORY \
--scan_code $GITHUB_REPOSITORY/$GITHUB_REF_NAME \
--path $GITHUB_WORKSPACE/code.zip \
--reuse_identifications \
--chunked_upload \
--identification_reuse_type specific_project \
--specific_code $GITHUB_REPOSITORY \
--run_dependency_analysis \
--delta_only
7 changes: 3 additions & 4 deletions .github/workflows/linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Code linters
- name: Code formatting check
run: |
pip install -r requirements.txt
pycodestyle workbench-agent.py
pylint --errors-only --rcfile .pylintrc workbench-agent.py
pip install -e .[dev]
black --check workbench-agent.py api/



44 changes: 44 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# .github/workflows/tests.yml
name: Run Tests

# Run on pushes and pull requests
on:
push:
paths-ignore:
- '*.md'
- '.gitignore'
pull_request:
paths-ignore:
- '*.md'
- '.gitignore'

jobs:
unit_tests:
name: Unit Tests (Python ${{ matrix.python-version }})
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12']
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .[dev,test]

- name: Run unit tests
run: |
pytest tests/unit/ -v --tb=short

- name: Run tests with coverage (Python 3.11 only)
if: matrix.python-version == '3.11'
run: |
pip install coverage pytest-cov
pytest tests/unit/ --cov=api --cov-report=xml --cov-report=term-missing
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,10 @@
Thumbs.db

# Log file
log-agent.txt
log-agent.txt

# Sample Code
inspiration/
test-commands.txt
original-wb-agent.py
workbench-agent-log.txt
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM cgr.dev/chainguard/python:latest-dev as builder
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt --user
COPY pyproject.toml .
RUN pip install -e . --user

FROM cgr.dev/chainguard/python:latest
WORKDIR /app
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,4 +235,4 @@ Linting
Run pylint in order reveal possible issues:
```bash
pylint workbench-agent.py
```
```
113 changes: 113 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
[build-system]
requires = ["setuptools>=45", "wheel", "setuptools_scm[toml]>=6.2"]

[project]
name = "workbench-agent"
version = "0.8.0"
description = "FossID Workbench Agent - Modular API client for automated scanning"
requires-python = ">=3.9"
dependencies = [
"requests",
"python-dotenv",
]

[project.optional-dependencies]
dev = [
"black",
]
test = [
"pytest>=7.0.0",
"pytest-mock>=3.6.1",
"requests>=2.25.1",
]

[tool.black]
line-length = 100
target-version = ['py39']
include = '\.pyi?$'
exclude = '''
/(
\.eggs
| \.git
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| _build
| buck-out
| build
| dist
| inspiration
)/
'''

[tool.setuptools.packages.find]
where = ["src"]

[tool.isort]
profile = "black"
line_length = 100
multi_line_output = 3
include_trailing_comma = true
force_grid_wrap = 0
use_parentheses = true
ensure_newline_before_comments = true
skip = ["inspiration"]

[tool.mypy]
python_version = "3.9"
warn_return_any = true
warn_unused_configs = true
disallow_untyped_defs = false
disallow_incomplete_defs = false
check_untyped_defs = true
disallow_untyped_decorators = false
no_implicit_optional = true
warn_redundant_casts = true
warn_unused_ignores = true
warn_no_return = true
warn_unreachable = true
strict_equality = true
exclude = [
"inspiration/",
"build/",
"dist/"
]

[tool.coverage.run]
source = ["api"]
omit = [
"*/tests/*",
"*/inspiration/*",
"*/__pycache__/*"
]

[tool.coverage.report]
exclude_lines = [
"pragma: no cover",
"def __repr__",
"if self.debug:",
"if settings.DEBUG",
"raise AssertionError",
"raise NotImplementedError",
"if 0:",
"if __name__ == .__main__.:"
]

[tool.pytest.ini_options]
testpaths = ["tests"]
python_files = ["test_*.py"]
python_classes = ["Test*"]
python_functions = ["test_*"]
addopts = [
"-v",
"--tb=short",
"--strict-markers"
]
markers = [
"unit: Unit tests",
"integration: Integration tests",
"slow: Slow-running tests"
]


5 changes: 0 additions & 5 deletions requirements.txt

This file was deleted.

5 changes: 0 additions & 5 deletions setup.cfg

This file was deleted.

15 changes: 15 additions & 0 deletions src/workbench_agent.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Metadata-Version: 2.4
Name: workbench-agent
Version: 0.7.1
Summary: FossID Workbench Agent - Modular API client for automated scanning
Requires-Python: >=3.9
License-File: LICENSE
Requires-Dist: requests
Requires-Dist: python-dotenv
Provides-Extra: dev
Requires-Dist: black; extra == "dev"
Provides-Extra: test
Requires-Dist: pytest>=7.0.0; extra == "test"
Requires-Dist: pytest-mock>=3.6.1; extra == "test"
Requires-Dist: requests>=2.25.1; extra == "test"
Dynamic: license-file
50 changes: 50 additions & 0 deletions src/workbench_agent.egg-info/SOURCES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
.dockerignore
.gitignore
.pylintrc
Dockerfile
LICENSE
README.md
pyproject.toml
workbench-agent.py
.github/workflows/build-image.yml
.github/workflows/dogfood.yml
.github/workflows/linters.yml
.github/workflows/tests.yml
api/__init__.py
api/projects_api.py
api/scans_api.py
api/upload_api.py
api/workbench_api.py
api/helpers/__init__.py
api/helpers/api_base.py
api/helpers/exceptions.py
api/helpers/process_waiters.py
api/helpers/project_scan_checks.py
api/helpers/status_checkers.py
api/helpers/upload_helpers.py
src/workbench_agent/__init__.py
src/workbench_agent.egg-info/PKG-INFO
src/workbench_agent.egg-info/SOURCES.txt
src/workbench_agent.egg-info/dependency_links.txt
src/workbench_agent.egg-info/requires.txt
src/workbench_agent.egg-info/top_level.txt
src/workbench_agent/api/__init__.py
src/workbench_agent/api/projects_api.py
src/workbench_agent/api/scans_api.py
src/workbench_agent/api/upload_api.py
src/workbench_agent/api/workbench_api.py
src/workbench_agent/api/helpers/__init__.py
src/workbench_agent/api/helpers/api_base.py
src/workbench_agent/api/helpers/process_waiters.py
src/workbench_agent/api/helpers/project_scan_checks.py
src/workbench_agent/api/helpers/status_checkers.py
src/workbench_agent/api/helpers/upload_helpers.py
src/workbench_agent/utilities/__init__.py
src/workbench_agent/utilities/error_handling.py
src/workbench_agent/utilities/exceptions.py
tests/__init__.py
tests/unit/__init__.py
tests/unit/api/__init__.py
tests/unit/api/test_projects_api.py
tests/unit/api/test_scans_api.py
tests/unit/api/test_workbench_api.py
1 change: 1 addition & 0 deletions src/workbench_agent.egg-info/dependency_links.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

10 changes: 10 additions & 0 deletions src/workbench_agent.egg-info/requires.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
requests
python-dotenv

[dev]
black

[test]
pytest>=7.0.0
pytest-mock>=3.6.1
requests>=2.25.1
1 change: 1 addition & 0 deletions src/workbench_agent.egg-info/top_level.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
workbench_agent
11 changes: 11 additions & 0 deletions src/workbench_agent/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"""
FossID Workbench Agent - Modular API client for automated scanning
"""

__version__ = "0.8.0"

# Import main API class
from .api import WorkbenchAPI

# Keep backward compatibility by creating an alias
Workbench = WorkbenchAPI
10 changes: 10 additions & 0 deletions src/workbench_agent/api/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"""
API modules for FossID Workbench Agent
"""

from .projects_api import ProjectsAPI
from .scans_api import ScansAPI
from .upload_api import UploadAPI
from .workbench_api import WorkbenchAPI

__all__ = ["ProjectsAPI", "ScansAPI", "UploadAPI", "WorkbenchAPI"]
Loading
Loading