djcheckup 0.2.4__tar.gz → 0.2.5__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.
- {djcheckup-0.2.4 → djcheckup-0.2.5}/PKG-INFO +1 -1
- {djcheckup-0.2.4 → djcheckup-0.2.5}/pyproject.toml +4 -9
- {djcheckup-0.2.4 → djcheckup-0.2.5}/src/djcheckup/cli.py +1 -5
- {djcheckup-0.2.4 → djcheckup-0.2.5}/src/djcheckup/outputs.py +8 -4
- djcheckup-0.2.5/src/djcheckup/run.py +48 -0
- djcheckup-0.2.4/src/djcheckup/run.py +0 -29
- {djcheckup-0.2.4 → djcheckup-0.2.5}/LICENSE +0 -0
- {djcheckup-0.2.4 → djcheckup-0.2.5}/README.md +0 -0
- {djcheckup-0.2.4 → djcheckup-0.2.5}/src/djcheckup/__init__.py +0 -0
- {djcheckup-0.2.4 → djcheckup-0.2.5}/src/djcheckup/check_defs.py +0 -0
- {djcheckup-0.2.4 → djcheckup-0.2.5}/src/djcheckup/checks.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "djcheckup"
|
|
3
|
-
version = "0.2.
|
|
3
|
+
version = "0.2.5"
|
|
4
4
|
description = "DJ Checkup is a security scanner for Django sites."
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
authors = [{ name = "Stuart Maxwell", email = "stuart@amanzi.nz" }]
|
|
@@ -30,18 +30,13 @@ select = ["ALL"]
|
|
|
30
30
|
project-includes = ["src/djcheckup/**"]
|
|
31
31
|
|
|
32
32
|
[tool.ruff.lint.extend-per-file-ignores]
|
|
33
|
-
"tests/**" = ["S101", "ANN201", "ANN001", "ARG001"]
|
|
33
|
+
"tests/**" = ["S101", "ANN201", "ANN001", "ARG001", "PT011", "PGH003", "SLF001"]
|
|
34
34
|
|
|
35
35
|
[tool.ruff.lint.pydocstyle]
|
|
36
36
|
convention = "google" # Accepts: "google", "numpy", or "pep257".
|
|
37
37
|
|
|
38
38
|
[dependency-groups]
|
|
39
|
-
dev = [
|
|
40
|
-
"nox>=2025.5.1",
|
|
41
|
-
"pyrefly>=0.34.0",
|
|
42
|
-
"pytest>=8.4.2",
|
|
43
|
-
"pytest-cov>=7.0.0",
|
|
44
|
-
]
|
|
39
|
+
dev = ["nox>=2025.5.1", "pyrefly>=0.34.0", "pytest>=8.4.2", "pytest-cov>=7.0.0"]
|
|
45
40
|
|
|
46
41
|
[tool.pytest.ini_options]
|
|
47
42
|
pythonpath = "."
|
|
@@ -52,7 +47,7 @@ show_contexts = true
|
|
|
52
47
|
|
|
53
48
|
[tool.coverage.run]
|
|
54
49
|
branch = true
|
|
55
|
-
include = ["src/djcheckup
|
|
50
|
+
include = ["src/djcheckup/**"]
|
|
56
51
|
|
|
57
52
|
[tool.coverage.report]
|
|
58
53
|
# exclude_lines = ["if TYPE_CHECKING:", "# pragma: no cover"]
|
|
@@ -22,14 +22,10 @@ def run_checks(
|
|
|
22
22
|
] = False,
|
|
23
23
|
) -> None:
|
|
24
24
|
"""Run the DJ Checkup tool against a specific URL."""
|
|
25
|
-
checker = SiteChecker(url)
|
|
25
|
+
checker = SiteChecker(url=url)
|
|
26
26
|
results = checker.run_checks(all_checks)
|
|
27
27
|
|
|
28
28
|
if output_json:
|
|
29
29
|
rich.print_json(output_results_as_json(results))
|
|
30
30
|
else:
|
|
31
31
|
rich_output(results)
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
if __name__ == "__main__":
|
|
35
|
-
app()
|
|
@@ -25,10 +25,13 @@ def rich_output(check_results: SiteCheckResult) -> None:
|
|
|
25
25
|
emoji = ""
|
|
26
26
|
if result.result == CheckResult.SUCCESS:
|
|
27
27
|
emoji = "🟢 "
|
|
28
|
-
|
|
28
|
+
|
|
29
|
+
if result.result == CheckResult.FAILURE:
|
|
29
30
|
emoji = "🔴 "
|
|
30
|
-
|
|
31
|
+
|
|
32
|
+
if result.result == CheckResult.SKIPPED:
|
|
31
33
|
emoji = "🟡 "
|
|
34
|
+
|
|
32
35
|
display_result = emoji + result.result.value.capitalize()
|
|
33
36
|
table.add_row(result.name, display_result, Markdown(result.message))
|
|
34
37
|
|
|
@@ -43,8 +46,9 @@ def json_encoder(obj: object) -> str | int:
|
|
|
43
46
|
if isinstance(obj, CheckResult):
|
|
44
47
|
return obj.value
|
|
45
48
|
|
|
46
|
-
|
|
47
|
-
|
|
49
|
+
# The following should never happen since this encoder is only used for SeverityWeight and CheckResult
|
|
50
|
+
msg = f"Object of type {type(obj).__name__} is not JSON serialisable" # pragma: no cover
|
|
51
|
+
raise TypeError(msg) # pragma: no cover
|
|
48
52
|
|
|
49
53
|
|
|
50
54
|
def output_results_as_json(results: SiteCheckResult) -> str:
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"""Run the DJ Checkup security scanner."""
|
|
2
|
+
|
|
3
|
+
from typing import Literal, overload
|
|
4
|
+
|
|
5
|
+
import httpx
|
|
6
|
+
|
|
7
|
+
from djcheckup.check_defs import all_checks
|
|
8
|
+
from djcheckup.checks import SiteChecker, SiteCheckResult
|
|
9
|
+
from djcheckup.outputs import output_results_as_json
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@overload
|
|
13
|
+
def run_checks(
|
|
14
|
+
url: str,
|
|
15
|
+
output_format: Literal["object"] = "object",
|
|
16
|
+
client: httpx.Client | None = None,
|
|
17
|
+
) -> SiteCheckResult: ...
|
|
18
|
+
@overload
|
|
19
|
+
def run_checks(url: str, output_format: Literal["json"], client: httpx.Client | None = None) -> str: ...
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def run_checks(
|
|
23
|
+
url: str,
|
|
24
|
+
output_format: Literal["object", "json"] = "object",
|
|
25
|
+
client: httpx.Client | None = None,
|
|
26
|
+
) -> str | SiteCheckResult:
|
|
27
|
+
"""Run the DJ Checkup tool.
|
|
28
|
+
|
|
29
|
+
Args:
|
|
30
|
+
url: The URL to check.
|
|
31
|
+
output_format: The format of the output, either "object" or "json" (default: "object").
|
|
32
|
+
client: An optional HTTPX client to use for requests.
|
|
33
|
+
|
|
34
|
+
Returns:
|
|
35
|
+
The result of the checks, either as a JSON string or a SiteCheckResult object.
|
|
36
|
+
"""
|
|
37
|
+
with SiteChecker(url, client=client) as checker:
|
|
38
|
+
results = checker.run_checks(all_checks)
|
|
39
|
+
|
|
40
|
+
if output_format not in {"object", "json"}:
|
|
41
|
+
msg = f"Invalid output_format: {output_format!r}. Must be 'object' or 'json'."
|
|
42
|
+
raise ValueError(msg)
|
|
43
|
+
|
|
44
|
+
if output_format == "json":
|
|
45
|
+
return output_results_as_json(results)
|
|
46
|
+
|
|
47
|
+
# Default to object output
|
|
48
|
+
return results
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"""Run the DJ Checkup security scanner."""
|
|
2
|
-
|
|
3
|
-
from typing import Literal, overload
|
|
4
|
-
|
|
5
|
-
from djcheckup.check_defs import all_checks
|
|
6
|
-
from djcheckup.checks import SiteChecker, SiteCheckResult
|
|
7
|
-
from djcheckup.outputs import output_results_as_json
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
@overload
|
|
11
|
-
def run_checks(url: str, output_format: Literal["object"] = "object") -> SiteCheckResult: ...
|
|
12
|
-
@overload
|
|
13
|
-
def run_checks(url: str, output_format: Literal["json"]) -> str: ...
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
def run_checks(url: str, output_format: Literal["object", "json"] = "object") -> str | SiteCheckResult:
|
|
17
|
-
"""Run the DJ Checkup tool against a specific URL and returns a JSON string."""
|
|
18
|
-
with SiteChecker(url) as checker:
|
|
19
|
-
results = checker.run_checks(all_checks)
|
|
20
|
-
|
|
21
|
-
if output_format not in {"object", "json"}:
|
|
22
|
-
msg = f"Invalid output_format: {output_format!r}. Must be 'object' or 'json'."
|
|
23
|
-
raise ValueError(msg)
|
|
24
|
-
|
|
25
|
-
if output_format == "json":
|
|
26
|
-
return output_results_as_json(results)
|
|
27
|
-
|
|
28
|
-
# Default to object output
|
|
29
|
-
return str(results)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|