docksec 0.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ OPENAI_API_KEY= ""
docksec-0.0.1/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Advait Patel
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,6 @@
1
+ include LICENSE
2
+ include README.md
3
+ include requirements.txt
4
+ include .env.example
5
+ recursive-include testfiles *
6
+ global-exclude *.py[cod] __pycache__ *.so .DS_Store
docksec-0.0.1/PKG-INFO ADDED
@@ -0,0 +1,182 @@
1
+ Metadata-Version: 2.4
2
+ Name: docksec
3
+ Version: 0.0.1
4
+ Summary: AI-Powered Docker Security Analyzer
5
+ Home-page: https://github.com/advaitpatel/DockSec
6
+ Author: Advait Patel
7
+ Project-URL: Bug Tracker, https://github.com/advaitpatel/DockSec/issues
8
+ Project-URL: Documentation, https://github.com/advaitpatel/DockSec/blob/main/README.md
9
+ Project-URL: Source Code, https://github.com/advaitpatel/DockSec
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Operating System :: OS Independent
13
+ Requires-Python: >=3.12
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Requires-Dist: langchain
17
+ Requires-Dist: langchain-openai
18
+ Requires-Dist: python-dotenv
19
+ Requires-Dist: pandas
20
+ Requires-Dist: tqdm
21
+ Requires-Dist: colorama
22
+ Requires-Dist: rich
23
+ Requires-Dist: fpdf
24
+ Requires-Dist: setuptools
25
+ Dynamic: author
26
+ Dynamic: classifier
27
+ Dynamic: description
28
+ Dynamic: description-content-type
29
+ Dynamic: home-page
30
+ Dynamic: license-file
31
+ Dynamic: project-url
32
+ Dynamic: requires-dist
33
+ Dynamic: requires-python
34
+ Dynamic: summary
35
+
36
+ # DockSec - AI-Powered Docker Security Analyzer
37
+
38
+ ## Overview
39
+ DockSec is an open-source AI-powered tool designed to analyze Dockerfiles for security vulnerabilities, misconfigurations, and inefficiencies. It provides automated recommendations to enhance container security, reduce the attack surface, and improve compliance with industry best practices.
40
+
41
+ ## Features
42
+ - AI/ML-Powered Analysis: Uses AI models to detect vulnerabilities and suggest security improvements.
43
+ - Security Vulnerability Detection: Scans Dockerfiles for known security issues, CVEs, and misconfigurations.
44
+ - Best Practice Recommendations: Provides actionable insights to enhance security, minimize image size, and improve efficiency.
45
+ - Integration with Development Tools:
46
+ - VS Code extension for inline security suggestions.
47
+ - CI/CD pipeline support (GitHub Actions, GitLab CI, Jenkins).
48
+ - Compliance Checks: Aligns with CIS Benchmarks, Docker Security Best Practices, and OWASP guidelines.
49
+
50
+
51
+ ## Installation
52
+
53
+ Create a virtual environment
54
+ ```bash
55
+ python -m venv env
56
+ ```
57
+ Activate the environment
58
+ ```bash
59
+ env\Scripts\activate # for mac use "source env\bin\activate"
60
+ ```
61
+
62
+ Install the tool using pip:
63
+
64
+ ```bash
65
+ pip install -e .
66
+ ```
67
+
68
+ This will install the `docksec` using setup.py from local files.
69
+
70
+ To install Docksec using pypi you can simply run
71
+
72
+ ```bash
73
+ pip install docksec # it will load the docksec tool from pypi
74
+ ```
75
+
76
+ To completely use the AI scanning of docksec you have to setup the OPENAI-API-KEY
77
+
78
+ 🔹 PowerShell (Windows):
79
+ `$env:OPENAI_API_KEY = "your-secret-key"`
80
+
81
+ 🔹 Command Prompt (CMD on Windows):
82
+ `set OPENAI_API_KEY=your-secret-key`
83
+
84
+ 🔹 Bash/Zsh (Linux/macOS):
85
+ `export OPENAI_API_KEY="your-secret-key"`
86
+
87
+ 🔹 Or create a `.env` file with:
88
+ `OPENAI_API_KEY=your-secret-key`
89
+
90
+ ## Requirements
91
+
92
+ The following dependencies will be automatically installed:
93
+ - langchain
94
+ - langchain-openai
95
+ - python-dotenv
96
+ - pandas
97
+ - tqdm
98
+ - colorama
99
+ - rich
100
+ - fpdf
101
+ - setuptools
102
+
103
+ ## Usage
104
+
105
+ ### CLI Tool
106
+
107
+ After installation, you can use DockSec with a simple command:
108
+
109
+ ```bash
110
+ docksec path\to\Dockerfile
111
+ ```
112
+
113
+ #### Options:
114
+ - `-i, --image`: Specify Docker image ID for scanning (optional)
115
+ - `-o, --output`: Specify output file for the report (default: security_report.txt)
116
+ - `--ai-only`: Run only AI-based recommendations
117
+ - `--scan-only`: Run only Dockerfile/image scanning
118
+
119
+ ### Examples:
120
+
121
+ ```bash
122
+ # Basic analysis
123
+ docksec path\to\Dockerfile
124
+
125
+ # Analyze both Dockerfile and a specific image
126
+ docksec path\to\Dockerfile -i myimage:latest
127
+
128
+ # Only run AI recommendations
129
+ docksec path\to\Dockerfile --ai-only
130
+
131
+ # Only scan for vulnerabilities with custom output file
132
+ docksec path\to\Dockerfile --scan-only -o custom_report.txt
133
+ ```
134
+
135
+ ### Legacy Usage
136
+
137
+ You can still use the original commands:
138
+
139
+ ```bash
140
+ # For AI-based recommendations
141
+ python .\main.py "path\to\your\dockerfile"
142
+
143
+ # For scanning both Dockerfile and images
144
+ python docker_scanner.py <dockerfile_path> <image_name> [severity]
145
+ # Example: python docker_scanner.py .\Dockerfile myapp:latest CRITICAL,HIGH
146
+ ```
147
+
148
+ #### External Tools Setup
149
+
150
+ To check the Dockerfile as well as images for vulnerabilities, you need to setup Trivy and hadolint:
151
+
152
+ ```bash
153
+ python .\setup_external_tools.py
154
+ ```
155
+
156
+ For manual installation, refer to [Trivy](https://trivy.dev/v0.18.3/installation/) and [hadolint](https://github.com/hadolint/hadolint?tab=readme-ov-file#install) documentation.
157
+
158
+ ## CI/CD Integration
159
+ TBD
160
+
161
+ ## Roadmap
162
+ TBD
163
+
164
+ ## Contributing
165
+ We welcome contributions! To get started:
166
+ 1. Fork the repository.
167
+ 2. Create a new branch for your feature or fix.
168
+ 3. Commit your changes and submit a pull request.
169
+
170
+ ## License
171
+ This project is licensed under the MIT License - see the LICENSE file for details.
172
+
173
+ ## Get Involved
174
+ - ⭐ Star this repository to show support!
175
+ - 📢 Share your feedback via GitHub Issues.
176
+ - 📝 Write about DockSec and contribute to our documentation.
177
+
178
+ ## Contact
179
+ For questions or collaborations, reach out via:
180
+ - GitHub Discussions: DockSec Community
181
+ - Twitter: @yourhandle
182
+ - LinkedIn: Your Profile
@@ -0,0 +1,147 @@
1
+ # DockSec - AI-Powered Docker Security Analyzer
2
+
3
+ ## Overview
4
+ DockSec is an open-source AI-powered tool designed to analyze Dockerfiles for security vulnerabilities, misconfigurations, and inefficiencies. It provides automated recommendations to enhance container security, reduce the attack surface, and improve compliance with industry best practices.
5
+
6
+ ## Features
7
+ - AI/ML-Powered Analysis: Uses AI models to detect vulnerabilities and suggest security improvements.
8
+ - Security Vulnerability Detection: Scans Dockerfiles for known security issues, CVEs, and misconfigurations.
9
+ - Best Practice Recommendations: Provides actionable insights to enhance security, minimize image size, and improve efficiency.
10
+ - Integration with Development Tools:
11
+ - VS Code extension for inline security suggestions.
12
+ - CI/CD pipeline support (GitHub Actions, GitLab CI, Jenkins).
13
+ - Compliance Checks: Aligns with CIS Benchmarks, Docker Security Best Practices, and OWASP guidelines.
14
+
15
+
16
+ ## Installation
17
+
18
+ Create a virtual environment
19
+ ```bash
20
+ python -m venv env
21
+ ```
22
+ Activate the environment
23
+ ```bash
24
+ env\Scripts\activate # for mac use "source env\bin\activate"
25
+ ```
26
+
27
+ Install the tool using pip:
28
+
29
+ ```bash
30
+ pip install -e .
31
+ ```
32
+
33
+ This will install the `docksec` using setup.py from local files.
34
+
35
+ To install Docksec using pypi you can simply run
36
+
37
+ ```bash
38
+ pip install docksec # it will load the docksec tool from pypi
39
+ ```
40
+
41
+ To completely use the AI scanning of docksec you have to setup the OPENAI-API-KEY
42
+
43
+ 🔹 PowerShell (Windows):
44
+ `$env:OPENAI_API_KEY = "your-secret-key"`
45
+
46
+ 🔹 Command Prompt (CMD on Windows):
47
+ `set OPENAI_API_KEY=your-secret-key`
48
+
49
+ 🔹 Bash/Zsh (Linux/macOS):
50
+ `export OPENAI_API_KEY="your-secret-key"`
51
+
52
+ 🔹 Or create a `.env` file with:
53
+ `OPENAI_API_KEY=your-secret-key`
54
+
55
+ ## Requirements
56
+
57
+ The following dependencies will be automatically installed:
58
+ - langchain
59
+ - langchain-openai
60
+ - python-dotenv
61
+ - pandas
62
+ - tqdm
63
+ - colorama
64
+ - rich
65
+ - fpdf
66
+ - setuptools
67
+
68
+ ## Usage
69
+
70
+ ### CLI Tool
71
+
72
+ After installation, you can use DockSec with a simple command:
73
+
74
+ ```bash
75
+ docksec path\to\Dockerfile
76
+ ```
77
+
78
+ #### Options:
79
+ - `-i, --image`: Specify Docker image ID for scanning (optional)
80
+ - `-o, --output`: Specify output file for the report (default: security_report.txt)
81
+ - `--ai-only`: Run only AI-based recommendations
82
+ - `--scan-only`: Run only Dockerfile/image scanning
83
+
84
+ ### Examples:
85
+
86
+ ```bash
87
+ # Basic analysis
88
+ docksec path\to\Dockerfile
89
+
90
+ # Analyze both Dockerfile and a specific image
91
+ docksec path\to\Dockerfile -i myimage:latest
92
+
93
+ # Only run AI recommendations
94
+ docksec path\to\Dockerfile --ai-only
95
+
96
+ # Only scan for vulnerabilities with custom output file
97
+ docksec path\to\Dockerfile --scan-only -o custom_report.txt
98
+ ```
99
+
100
+ ### Legacy Usage
101
+
102
+ You can still use the original commands:
103
+
104
+ ```bash
105
+ # For AI-based recommendations
106
+ python .\main.py "path\to\your\dockerfile"
107
+
108
+ # For scanning both Dockerfile and images
109
+ python docker_scanner.py <dockerfile_path> <image_name> [severity]
110
+ # Example: python docker_scanner.py .\Dockerfile myapp:latest CRITICAL,HIGH
111
+ ```
112
+
113
+ #### External Tools Setup
114
+
115
+ To check the Dockerfile as well as images for vulnerabilities, you need to setup Trivy and hadolint:
116
+
117
+ ```bash
118
+ python .\setup_external_tools.py
119
+ ```
120
+
121
+ For manual installation, refer to [Trivy](https://trivy.dev/v0.18.3/installation/) and [hadolint](https://github.com/hadolint/hadolint?tab=readme-ov-file#install) documentation.
122
+
123
+ ## CI/CD Integration
124
+ TBD
125
+
126
+ ## Roadmap
127
+ TBD
128
+
129
+ ## Contributing
130
+ We welcome contributions! To get started:
131
+ 1. Fork the repository.
132
+ 2. Create a new branch for your feature or fix.
133
+ 3. Commit your changes and submit a pull request.
134
+
135
+ ## License
136
+ This project is licensed under the MIT License - see the LICENSE file for details.
137
+
138
+ ## Get Involved
139
+ - ⭐ Star this repository to show support!
140
+ - 📢 Share your feedback via GitHub Issues.
141
+ - 📝 Write about DockSec and contribute to our documentation.
142
+
143
+ ## Contact
144
+ For questions or collaborations, reach out via:
145
+ - GitHub Discussions: DockSec Community
146
+ - Twitter: @yourhandle
147
+ - LinkedIn: Your Profile
@@ -0,0 +1,182 @@
1
+ Metadata-Version: 2.4
2
+ Name: docksec
3
+ Version: 0.0.1
4
+ Summary: AI-Powered Docker Security Analyzer
5
+ Home-page: https://github.com/advaitpatel/DockSec
6
+ Author: Advait Patel
7
+ Project-URL: Bug Tracker, https://github.com/advaitpatel/DockSec/issues
8
+ Project-URL: Documentation, https://github.com/advaitpatel/DockSec/blob/main/README.md
9
+ Project-URL: Source Code, https://github.com/advaitpatel/DockSec
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Operating System :: OS Independent
13
+ Requires-Python: >=3.12
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Requires-Dist: langchain
17
+ Requires-Dist: langchain-openai
18
+ Requires-Dist: python-dotenv
19
+ Requires-Dist: pandas
20
+ Requires-Dist: tqdm
21
+ Requires-Dist: colorama
22
+ Requires-Dist: rich
23
+ Requires-Dist: fpdf
24
+ Requires-Dist: setuptools
25
+ Dynamic: author
26
+ Dynamic: classifier
27
+ Dynamic: description
28
+ Dynamic: description-content-type
29
+ Dynamic: home-page
30
+ Dynamic: license-file
31
+ Dynamic: project-url
32
+ Dynamic: requires-dist
33
+ Dynamic: requires-python
34
+ Dynamic: summary
35
+
36
+ # DockSec - AI-Powered Docker Security Analyzer
37
+
38
+ ## Overview
39
+ DockSec is an open-source AI-powered tool designed to analyze Dockerfiles for security vulnerabilities, misconfigurations, and inefficiencies. It provides automated recommendations to enhance container security, reduce the attack surface, and improve compliance with industry best practices.
40
+
41
+ ## Features
42
+ - AI/ML-Powered Analysis: Uses AI models to detect vulnerabilities and suggest security improvements.
43
+ - Security Vulnerability Detection: Scans Dockerfiles for known security issues, CVEs, and misconfigurations.
44
+ - Best Practice Recommendations: Provides actionable insights to enhance security, minimize image size, and improve efficiency.
45
+ - Integration with Development Tools:
46
+ - VS Code extension for inline security suggestions.
47
+ - CI/CD pipeline support (GitHub Actions, GitLab CI, Jenkins).
48
+ - Compliance Checks: Aligns with CIS Benchmarks, Docker Security Best Practices, and OWASP guidelines.
49
+
50
+
51
+ ## Installation
52
+
53
+ Create a virtual environment
54
+ ```bash
55
+ python -m venv env
56
+ ```
57
+ Activate the environment
58
+ ```bash
59
+ env\Scripts\activate # for mac use "source env\bin\activate"
60
+ ```
61
+
62
+ Install the tool using pip:
63
+
64
+ ```bash
65
+ pip install -e .
66
+ ```
67
+
68
+ This will install the `docksec` using setup.py from local files.
69
+
70
+ To install Docksec using pypi you can simply run
71
+
72
+ ```bash
73
+ pip install docksec # it will load the docksec tool from pypi
74
+ ```
75
+
76
+ To completely use the AI scanning of docksec you have to setup the OPENAI-API-KEY
77
+
78
+ 🔹 PowerShell (Windows):
79
+ `$env:OPENAI_API_KEY = "your-secret-key"`
80
+
81
+ 🔹 Command Prompt (CMD on Windows):
82
+ `set OPENAI_API_KEY=your-secret-key`
83
+
84
+ 🔹 Bash/Zsh (Linux/macOS):
85
+ `export OPENAI_API_KEY="your-secret-key"`
86
+
87
+ 🔹 Or create a `.env` file with:
88
+ `OPENAI_API_KEY=your-secret-key`
89
+
90
+ ## Requirements
91
+
92
+ The following dependencies will be automatically installed:
93
+ - langchain
94
+ - langchain-openai
95
+ - python-dotenv
96
+ - pandas
97
+ - tqdm
98
+ - colorama
99
+ - rich
100
+ - fpdf
101
+ - setuptools
102
+
103
+ ## Usage
104
+
105
+ ### CLI Tool
106
+
107
+ After installation, you can use DockSec with a simple command:
108
+
109
+ ```bash
110
+ docksec path\to\Dockerfile
111
+ ```
112
+
113
+ #### Options:
114
+ - `-i, --image`: Specify Docker image ID for scanning (optional)
115
+ - `-o, --output`: Specify output file for the report (default: security_report.txt)
116
+ - `--ai-only`: Run only AI-based recommendations
117
+ - `--scan-only`: Run only Dockerfile/image scanning
118
+
119
+ ### Examples:
120
+
121
+ ```bash
122
+ # Basic analysis
123
+ docksec path\to\Dockerfile
124
+
125
+ # Analyze both Dockerfile and a specific image
126
+ docksec path\to\Dockerfile -i myimage:latest
127
+
128
+ # Only run AI recommendations
129
+ docksec path\to\Dockerfile --ai-only
130
+
131
+ # Only scan for vulnerabilities with custom output file
132
+ docksec path\to\Dockerfile --scan-only -o custom_report.txt
133
+ ```
134
+
135
+ ### Legacy Usage
136
+
137
+ You can still use the original commands:
138
+
139
+ ```bash
140
+ # For AI-based recommendations
141
+ python .\main.py "path\to\your\dockerfile"
142
+
143
+ # For scanning both Dockerfile and images
144
+ python docker_scanner.py <dockerfile_path> <image_name> [severity]
145
+ # Example: python docker_scanner.py .\Dockerfile myapp:latest CRITICAL,HIGH
146
+ ```
147
+
148
+ #### External Tools Setup
149
+
150
+ To check the Dockerfile as well as images for vulnerabilities, you need to setup Trivy and hadolint:
151
+
152
+ ```bash
153
+ python .\setup_external_tools.py
154
+ ```
155
+
156
+ For manual installation, refer to [Trivy](https://trivy.dev/v0.18.3/installation/) and [hadolint](https://github.com/hadolint/hadolint?tab=readme-ov-file#install) documentation.
157
+
158
+ ## CI/CD Integration
159
+ TBD
160
+
161
+ ## Roadmap
162
+ TBD
163
+
164
+ ## Contributing
165
+ We welcome contributions! To get started:
166
+ 1. Fork the repository.
167
+ 2. Create a new branch for your feature or fix.
168
+ 3. Commit your changes and submit a pull request.
169
+
170
+ ## License
171
+ This project is licensed under the MIT License - see the LICENSE file for details.
172
+
173
+ ## Get Involved
174
+ - ⭐ Star this repository to show support!
175
+ - 📢 Share your feedback via GitHub Issues.
176
+ - 📝 Write about DockSec and contribute to our documentation.
177
+
178
+ ## Contact
179
+ For questions or collaborations, reach out via:
180
+ - GitHub Discussions: DockSec Community
181
+ - Twitter: @yourhandle
182
+ - LinkedIn: Your Profile
@@ -0,0 +1,15 @@
1
+ .env.example
2
+ LICENSE
3
+ MANIFEST.in
4
+ README.md
5
+ docksec.py
6
+ pyproject.toml
7
+ requirements.txt
8
+ setup.py
9
+ docksec.egg-info/PKG-INFO
10
+ docksec.egg-info/SOURCES.txt
11
+ docksec.egg-info/dependency_links.txt
12
+ docksec.egg-info/entry_points.txt
13
+ docksec.egg-info/requires.txt
14
+ docksec.egg-info/top_level.txt
15
+ testfiles/2/Dockerfile
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ docksec = docksec:main
@@ -0,0 +1,9 @@
1
+ langchain
2
+ langchain-openai
3
+ python-dotenv
4
+ pandas
5
+ tqdm
6
+ colorama
7
+ rich
8
+ fpdf
9
+ setuptools
@@ -0,0 +1 @@
1
+ docksec
@@ -0,0 +1,51 @@
1
+ #!/usr/bin/env python3
2
+
3
+ import sys
4
+ import os
5
+ import argparse
6
+ import subprocess
7
+
8
+ def main():
9
+ parser = argparse.ArgumentParser(description='Docker Security Analysis Tool')
10
+ parser.add_argument('dockerfile', help='Path to the Dockerfile to analyze')
11
+ parser.add_argument('-i', '--image', help='Docker image ID to scan (optional)')
12
+ parser.add_argument('-o', '--output', help='Output file for the report (default: security_report.txt)')
13
+ parser.add_argument('--ai-only', action='store_true', help='Run only AI-based recommendations')
14
+ parser.add_argument('--scan-only', action='store_true', help='Run only Dockerfile/image scanning')
15
+
16
+ args = parser.parse_args()
17
+
18
+ # Validate that the Dockerfile exists
19
+ if not os.path.isfile(args.dockerfile):
20
+ print(f"Error: Dockerfile not found at {args.dockerfile}")
21
+ sys.exit(1)
22
+
23
+ # Determine which tools to run
24
+ run_ai = not args.scan_only
25
+ run_scan = not args.ai_only
26
+
27
+ if not run_ai and not run_scan:
28
+ run_ai = run_scan = True # Run both by default
29
+
30
+ # Run the AI-based recommendation tool
31
+ if run_ai:
32
+ print("Running AI-based Dockerfile analysis...")
33
+ # Using list form to avoid shell parsing issues on Windows
34
+ subprocess.run([sys.executable, "main.py", args.dockerfile])
35
+
36
+ # Run the scanner tool
37
+ if run_scan:
38
+ print("Running Dockerfile and image scanner...")
39
+ output_file = args.output or "security_report.txt"
40
+ image_id = args.image or ""
41
+
42
+ cmd = [sys.executable, "docker_scanner.py", args.dockerfile]
43
+ if image_id:
44
+ cmd.append(image_id)
45
+
46
+ subprocess.run(cmd)
47
+
48
+ print("Analysis complete!")
49
+
50
+ if __name__ == "__main__":
51
+ main()
@@ -0,0 +1,12 @@
1
+ [build-system]
2
+ requires = ["setuptools>=42", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [tool.black]
6
+ line-length = 88
7
+ target-version = ['py38']
8
+ include = '\.pyi?$'
9
+
10
+ [tool.isort]
11
+ profile = "black"
12
+ multi_line_output = 3
@@ -0,0 +1,11 @@
1
+ langchain
2
+ langchain-openai
3
+ python-dotenv
4
+ pandas
5
+
6
+ tqdm
7
+ colorama
8
+ rich
9
+
10
+ fpdf
11
+ setuptools
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
docksec-0.0.1/setup.py ADDED
@@ -0,0 +1,40 @@
1
+ from setuptools import setup
2
+
3
+ setup(
4
+ name="docksec",
5
+ version="0.0.1",
6
+ description="AI-Powered Docker Security Analyzer",
7
+ long_description=open("README.md").read(),
8
+ long_description_content_type="text/markdown",
9
+ author="Advait Patel",
10
+ url="https://github.com/advaitpatel/DockSec",
11
+ py_modules=["docksec"],
12
+ entry_points={
13
+ "console_scripts": [
14
+ "docksec=docksec:main",
15
+ ],
16
+ },
17
+ project_urls={
18
+ "Bug Tracker": "https://github.com/advaitpatel/DockSec/issues",
19
+ "Documentation": "https://github.com/advaitpatel/DockSec/blob/main/README.md",
20
+ "Source Code": "https://github.com/advaitpatel/DockSec",
21
+ },
22
+ python_requires=">=3.12",
23
+ install_requires=[
24
+ "langchain",
25
+ "langchain-openai",
26
+ "python-dotenv",
27
+ "pandas",
28
+ "tqdm",
29
+ "colorama",
30
+ "rich",
31
+ "fpdf",
32
+ "setuptools",
33
+ ],
34
+ classifiers=[
35
+ "Programming Language :: Python :: 3",
36
+ "License :: OSI Approved :: MIT License",
37
+ "Operating System :: OS Independent",
38
+ ],
39
+ include_package_data=True,
40
+ )
@@ -0,0 +1,176 @@
1
+ # syntax=docker/dockerfile:1
2
+ # Initialize device type args
3
+ # use build args in the docker build command with --build-arg="BUILDARG=true"
4
+ ARG USE_CUDA=false
5
+ ARG USE_OLLAMA=false
6
+ # Tested with cu117 for CUDA 11 and cu121 for CUDA 12 (default)
7
+ ARG USE_CUDA_VER=cu121
8
+ # any sentence transformer model; models to use can be found at https://huggingface.co/models?library=sentence-transformers
9
+ # Leaderboard: https://huggingface.co/spaces/mteb/leaderboard
10
+ # for better performance and multilangauge support use "intfloat/multilingual-e5-large" (~2.5GB) or "intfloat/multilingual-e5-base" (~1.5GB)
11
+ # IMPORTANT: If you change the embedding model (sentence-transformers/all-MiniLM-L6-v2) and vice versa, you aren't able to use RAG Chat with your previous documents loaded in the WebUI! You need to re-embed them.
12
+ ARG USE_EMBEDDING_MODEL=sentence-transformers/all-MiniLM-L6-v2
13
+ ARG USE_RERANKING_MODEL=""
14
+
15
+ # Tiktoken encoding name; models to use can be found at https://huggingface.co/models?library=tiktoken
16
+ ARG USE_TIKTOKEN_ENCODING_NAME="cl100k_base"
17
+
18
+ ARG BUILD_HASH=dev-build
19
+ # Override at your own risk - non-root configurations are untested
20
+ ARG UID=0
21
+ ARG GID=0
22
+
23
+ ######## WebUI frontend ########
24
+ FROM --platform=$BUILDPLATFORM node:22-alpine3.20 AS build
25
+ ARG BUILD_HASH
26
+
27
+ WORKDIR /app
28
+
29
+ COPY package.json package-lock.json ./
30
+ RUN npm ci
31
+
32
+ COPY . .
33
+ ENV APP_BUILD_HASH=${BUILD_HASH}
34
+ RUN npm run build
35
+
36
+ ######## WebUI backend ########
37
+ FROM python:3.11-slim-bookworm AS base
38
+
39
+ # Use args
40
+ ARG USE_CUDA
41
+ ARG USE_OLLAMA
42
+ ARG USE_CUDA_VER
43
+ ARG USE_EMBEDDING_MODEL
44
+ ARG USE_RERANKING_MODEL
45
+ ARG UID
46
+ ARG GID
47
+
48
+ ## Basis ##
49
+ ENV ENV=prod \
50
+ PORT=8080 \
51
+ # pass build args to the build
52
+ USE_OLLAMA_DOCKER=${USE_OLLAMA} \
53
+ USE_CUDA_DOCKER=${USE_CUDA} \
54
+ USE_CUDA_DOCKER_VER=${USE_CUDA_VER} \
55
+ USE_EMBEDDING_MODEL_DOCKER=${USE_EMBEDDING_MODEL} \
56
+ USE_RERANKING_MODEL_DOCKER=${USE_RERANKING_MODEL}
57
+
58
+ ## Basis URL Config ##
59
+ ENV OLLAMA_BASE_URL="/ollama" \
60
+ OPENAI_API_BASE_URL=""
61
+
62
+ ## API Key and Security Config ##
63
+ ENV OPENAI_API_KEY="" \
64
+ WEBUI_SECRET_KEY="" \
65
+ SCARF_NO_ANALYTICS=true \
66
+ DO_NOT_TRACK=true \
67
+ ANONYMIZED_TELEMETRY=false
68
+
69
+ #### Other models #########################################################
70
+ ## whisper TTS model settings ##
71
+ ENV WHISPER_MODEL="base" \
72
+ WHISPER_MODEL_DIR="/app/backend/data/cache/whisper/models"
73
+
74
+ ## RAG Embedding model settings ##
75
+ ENV RAG_EMBEDDING_MODEL="$USE_EMBEDDING_MODEL_DOCKER" \
76
+ RAG_RERANKING_MODEL="$USE_RERANKING_MODEL_DOCKER" \
77
+ SENTENCE_TRANSFORMERS_HOME="/app/backend/data/cache/embedding/models"
78
+
79
+ ## Tiktoken model settings ##
80
+ ENV TIKTOKEN_ENCODING_NAME="cl100k_base" \
81
+ TIKTOKEN_CACHE_DIR="/app/backend/data/cache/tiktoken"
82
+
83
+ ## Hugging Face download cache ##
84
+ ENV HF_HOME="/app/backend/data/cache/embedding/models"
85
+
86
+ ## Torch Extensions ##
87
+ # ENV TORCH_EXTENSIONS_DIR="/.cache/torch_extensions"
88
+
89
+ #### Other models ##########################################################
90
+
91
+ WORKDIR /app/backend
92
+
93
+ ENV HOME=/root
94
+ # Create user and group if not root
95
+ RUN if [ $UID -ne 0 ]; then \
96
+ if [ $GID -ne 0 ]; then \
97
+ addgroup --gid $GID app; \
98
+ fi; \
99
+ adduser --uid $UID --gid $GID --home $HOME --disabled-password --no-create-home app; \
100
+ fi
101
+
102
+ RUN mkdir -p $HOME/.cache/chroma
103
+ RUN echo -n 00000000-0000-0000-0000-000000000000 > $HOME/.cache/chroma/telemetry_user_id
104
+
105
+ # Make sure the user has access to the app and root directory
106
+ RUN chown -R $UID:$GID /app $HOME
107
+
108
+ RUN if [ "$USE_OLLAMA" = "true" ]; then \
109
+ apt-get update && \
110
+ # Install pandoc and netcat
111
+ apt-get install -y --no-install-recommends git build-essential pandoc netcat-openbsd curl && \
112
+ apt-get install -y --no-install-recommends gcc python3-dev && \
113
+ # for RAG OCR
114
+ apt-get install -y --no-install-recommends ffmpeg libsm6 libxext6 && \
115
+ # install helper tools
116
+ apt-get install -y --no-install-recommends curl jq && \
117
+ # install ollama
118
+ curl -fsSL https://ollama.com/install.sh | sh && \
119
+ # cleanup
120
+ rm -rf /var/lib/apt/lists/*; \
121
+ else \
122
+ apt-get update && \
123
+ # Install pandoc, netcat and gcc
124
+ apt-get install -y --no-install-recommends git build-essential pandoc gcc netcat-openbsd curl jq && \
125
+ apt-get install -y --no-install-recommends gcc python3-dev && \
126
+ # for RAG OCR
127
+ apt-get install -y --no-install-recommends ffmpeg libsm6 libxext6 && \
128
+ # cleanup
129
+ rm -rf /var/lib/apt/lists/*; \
130
+ fi
131
+
132
+ # install python dependencies
133
+ COPY --chown=$UID:$GID ./backend/requirements.txt ./requirements.txt
134
+
135
+ RUN pip3 install uv && \
136
+ if [ "$USE_CUDA" = "true" ]; then \
137
+ # If you use CUDA the whisper and embedding model will be downloaded on first use
138
+ pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/$USE_CUDA_DOCKER_VER --no-cache-dir && \
139
+ uv pip install --system -r requirements.txt --no-cache-dir && \
140
+ python -c "import os; from sentence_transformers import SentenceTransformer; SentenceTransformer(os.environ['RAG_EMBEDDING_MODEL'], device='cpu')" && \
141
+ python -c "import os; from faster_whisper import WhisperModel; WhisperModel(os.environ['WHISPER_MODEL'], device='cpu', compute_type='int8', download_root=os.environ['WHISPER_MODEL_DIR'])"; \
142
+ python -c "import os; import tiktoken; tiktoken.get_encoding(os.environ['TIKTOKEN_ENCODING_NAME'])"; \
143
+ else \
144
+ pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu --no-cache-dir && \
145
+ uv pip install --system -r requirements.txt --no-cache-dir && \
146
+ python -c "import os; from sentence_transformers import SentenceTransformer; SentenceTransformer(os.environ['RAG_EMBEDDING_MODEL'], device='cpu')" && \
147
+ python -c "import os; from faster_whisper import WhisperModel; WhisperModel(os.environ['WHISPER_MODEL'], device='cpu', compute_type='int8', download_root=os.environ['WHISPER_MODEL_DIR'])"; \
148
+ python -c "import os; import tiktoken; tiktoken.get_encoding(os.environ['TIKTOKEN_ENCODING_NAME'])"; \
149
+ fi; \
150
+ chown -R $UID:$GID /app/backend/data/
151
+
152
+
153
+
154
+ # copy embedding weight from build
155
+ # RUN mkdir -p /root/.cache/chroma/onnx_models/all-MiniLM-L6-v2
156
+ # COPY --from=build /app/onnx /root/.cache/chroma/onnx_models/all-MiniLM-L6-v2/onnx
157
+
158
+ # copy built frontend files
159
+ COPY --chown=$UID:$GID --from=build /app/build /app/build
160
+ COPY --chown=$UID:$GID --from=build /app/CHANGELOG.md /app/CHANGELOG.md
161
+ COPY --chown=$UID:$GID --from=build /app/package.json /app/package.json
162
+
163
+ # copy backend files
164
+ COPY --chown=$UID:$GID ./backend .
165
+
166
+ EXPOSE 8080
167
+
168
+ HEALTHCHECK CMD curl --silent --fail http://localhost:${PORT:-8080}/health | jq -ne 'input.status == true' || exit 1
169
+
170
+ USER $UID:$GID
171
+
172
+ ARG BUILD_HASH
173
+ ENV WEBUI_BUILD_VERSION=${BUILD_HASH}
174
+ ENV DOCKER=true
175
+
176
+ CMD [ "bash", "start.sh"]