Skip to content

Commit cda0ec2

Browse files
committed
updates to include cov, scripts for security scan
1 parent 7422bc2 commit cda0ec2

File tree

7 files changed

+148
-1
lines changed

7 files changed

+148
-1
lines changed

coverage.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" ?>
2-
<coverage version="7.11.0" timestamp="1762115605319" lines-valid="563" lines-covered="287" line-rate="0.5098" branches-valid="134" branches-covered="35" branch-rate="0.2612" complexity="0">
2+
<coverage version="7.11.0" timestamp="1762119452943" lines-valid="563" lines-covered="287" line-rate="0.5098" branches-valid="134" branches-covered="35" branch-rate="0.2612" complexity="0">
33
<!-- Generated by coverage.py: https://coverage.readthedocs.io/en/7.11.0 -->
44
<!-- Based on https://raw.githubusercontent.com/cobertura/web/master/htdocs/xml/coverage-04.dtd -->
55
<sources>

docs/_static/.gitkeep

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Keep this directory for Sphinx static files

docs/conf.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Configuration file for the Sphinx documentation builder.
2+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
3+
4+
# -- Project information -----------------------------------------------------
5+
project = "SiteScanner5000"
6+
copyright = "2025, SiteScanner Contributors"
7+
author = "SiteScanner Contributors"
8+
release = "0.1.0"
9+
10+
# -- General configuration ---------------------------------------------------
11+
extensions = [
12+
"sphinx.ext.autodoc",
13+
"sphinx.ext.napoleon",
14+
"sphinx.ext.viewcode",
15+
]
16+
17+
templates_path = ["_templates"]
18+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
19+
20+
# -- Options for HTML output -------------------------------------------------
21+
html_theme = "sphinx_rtd_theme"
22+
html_static_path = ["_static"]

docs/index.rst

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
SiteScanner5000 Documentation
2+
==============================
3+
4+
.. toctree::
5+
:maxdepth: 2
6+
:caption: Contents:
7+
8+
installation
9+
usage
10+
api
11+
12+
Welcome to SiteScanner5000
13+
--------------------------
14+
15+
Automated security scanner for web applications that identifies common vulnerabilities including SQL injection, XSS, CSRF, and misconfigurations.
16+
17+
Features
18+
--------
19+
20+
* SQL Injection Detection
21+
* Cross-Site Scripting (XSS) Detection
22+
* CSRF Protection Validation
23+
* Security Headers Check
24+
* TLS Configuration Check
25+
* Async Scanning Support
26+
27+
Quick Start
28+
-----------
29+
30+
Install using uv:
31+
32+
.. code-block:: bash
33+
34+
uv add sitescanner5000
35+
36+
Basic usage:
37+
38+
.. code-block:: bash
39+
40+
sitescanner scan https://example.com
41+
42+
Indices and tables
43+
==================
44+
45+
* :ref:`genindex`
46+
* :ref:`modindex`
47+
* :ref:`search`

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ line-length = 100
167167
target-version = "py311"
168168
src = ["src", "tests"]
169169
extend-include = ["*.ipynb"]
170+
extend-exclude = ["scripts", "docs"]
170171

171172
[tool.ruff.lint]
172173
select = [

scripts/security_bandit_check.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env python3
2+
"""Check Bandit security scan results against threshold."""
3+
4+
import json
5+
import os
6+
from pathlib import Path
7+
import sys
8+
9+
10+
def main() -> None:
11+
"""Check bandit results against SECURITY_FAIL_LEVEL threshold."""
12+
fail_level = os.getenv("SECURITY_FAIL_LEVEL", "MEDIUM").upper()
13+
severity_order = ["LOW", "MEDIUM", "HIGH"]
14+
15+
if fail_level not in severity_order:
16+
print(f"Invalid SECURITY_FAIL_LEVEL: {fail_level}")
17+
sys.exit(1)
18+
19+
threshold_index = severity_order.index(fail_level)
20+
21+
report_path = Path("bandit-report.json")
22+
if not report_path.exists():
23+
print("No bandit-report.json found, skipping.")
24+
return
25+
26+
with report_path.open() as f:
27+
data = json.load(f)
28+
29+
results = data.get("results", [])
30+
issues_above_threshold = [
31+
r for r in results
32+
if severity_order.index(r["issue_severity"]) >= threshold_index
33+
]
34+
35+
if issues_above_threshold:
36+
print(f"❌ Found {len(issues_above_threshold)} Bandit issues at or above {fail_level} severity:")
37+
for issue in issues_above_threshold:
38+
print(f" - {issue['issue_text']} ({issue['issue_severity']}) in {issue['filename']}:{issue['line_number']}")
39+
sys.exit(1)
40+
else:
41+
print(f"✅ No Bandit issues at or above {fail_level} severity.")
42+
43+
44+
if __name__ == "__main__":
45+
main()

scripts/security_safety_check.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env python3
2+
"""Check Safety security scan results for vulnerabilities."""
3+
4+
import json
5+
from pathlib import Path
6+
import sys
7+
8+
9+
def main() -> None:
10+
"""Check safety results for any vulnerabilities."""
11+
report_path = Path("safety-report.json")
12+
if not report_path.exists():
13+
print("No safety-report.json found, skipping.")
14+
return
15+
16+
with report_path.open() as f:
17+
data = json.load(f)
18+
19+
vulnerabilities = data.get("vulnerabilities", [])
20+
21+
if vulnerabilities:
22+
print(f"❌ Found {len(vulnerabilities)} Safety vulnerabilities:")
23+
for vuln in vulnerabilities:
24+
print(f" - {vuln.get('package_name', 'Unknown')}: {vuln.get('vulnerability', 'Unknown issue')}")
25+
sys.exit(1)
26+
else:
27+
print("✅ No Safety vulnerabilities found.")
28+
29+
30+
if __name__ == "__main__":
31+
main()

0 commit comments

Comments
 (0)