Skip to content
Merged
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
71 changes: 71 additions & 0 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Python Application CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:

jobs:
build-and-test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12'

- name: Setup Hadolint
run: |
curl -sL -o hadolint https://github.com/hadolint/hadolint/releases/latest/download/hadolint-Linux-x86_64
chmod +x hadolint
sudo mv hadolint /usr/local/bin/

- name: Setup Trivy
run: |
curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b /usr/local/bin v0.43.1

- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi

- name: Build package
run: |
pip install build
python -m build

- name: Install package in development mode
run: |
pip install -e .

- name: Run Hadolint on Dockerfiles
run: |
find . -name "Dockerfile*" -exec hadolint {} \;

- name: Run Trivy for vulnerability scanning
run: |
find . -name "Dockerfile*" -exec trivy config {} \;

- name: Debug folder structure
run: |
echo "Current directory: $(pwd)"
ls -R

- name: Run tests
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
run: |
docksec -h
docksec --ai-only ./testfiles/2/Dockerfile

- name: Upload coverage report
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: coverage.xml
if-no-files-found: ignore
Binary file removed DockSecPhase2.zip
Binary file not shown.
6 changes: 6 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
include LICENSE
include README.md
include requirements.txt
include .env.example
recursive-include testfiles *
global-exclude *.py[cod] __pycache__ *.so .DS_Store
28 changes: 26 additions & 2 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,34 @@
load_dotenv()


OPENAI_API_KEY = os.getenv("OPENAI_API_KEY","")
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY", "")

if not OPENAI_API_KEY:
raise ValueError("No OpenAI API Key provided. Set an API key in the OPENAI_API_KEY in the .env file.")
error_message = """
❌ No OpenAI API Key provided.

You can fix this by setting the `OPENAI_API_KEY` in one of the following ways:

🔹 PowerShell (Windows):
$env:OPENAI_API_KEY = "your-secret-key"

🔹 Command Prompt (CMD on Windows):
set OPENAI_API_KEY=your-secret-key

🔹 Bash/Zsh (Linux/macOS):
export OPENAI_API_KEY="your-secret-key"

🔹 Or create a `.env` file with:
OPENAI_API_KEY=your-secret-key


🔒 Reminder: Never hardcode your API key in public code or repositories. it is necessary to use Docksec

"""
raise EnvironmentError(error_message.strip())
else:
print("✅ OpenAI API Key found in environment variables.")


os.environ["OPENAI_API_KEY"] = OPENAI_API_KEY

Expand Down
12 changes: 12 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[build-system]
requires = ["setuptools>=42", "wheel"]
build-backend = "setuptools.build_meta"

[tool.black]
line-length = 88
target-version = ['py38']
include = '\.pyi?$'

[tool.isort]
profile = "black"
multi_line_output = 3
7 changes: 7 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
"docksec=docksec:main",
],
},
project_urls={
"Bug Tracker": "https://github.com/advaitpatel/DockSec/issues",
"Documentation": "https://github.com/advaitpatel/DockSec/blob/main/README.md",
"Source Code": "https://github.com/advaitpatel/DockSec",
},
python_requires=">=3.12",
install_requires=[
"langchain",
"langchain-openai",
Expand All @@ -22,4 +28,5 @@
"fpdf",
"setuptools",
],
include_package_data=True,
)