pyrig-codeql 1.0.2__tar.gz → 1.1.0__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.
Files changed (17) hide show
  1. {pyrig_codeql-1.0.2 → pyrig_codeql-1.1.0}/PKG-INFO +3 -1
  2. {pyrig_codeql-1.0.2 → pyrig_codeql-1.1.0}/README.md +2 -0
  3. {pyrig_codeql-1.0.2 → pyrig_codeql-1.1.0}/pyproject.toml +1 -1
  4. {pyrig_codeql-1.0.2 → pyrig_codeql-1.1.0}/pyproject.toml.orig +1 -1
  5. pyrig_codeql-1.1.0/src/pyrig_codeql/rig/configs/version_control/remote/code_analyzer.py +40 -0
  6. {pyrig_codeql-1.0.2 → pyrig_codeql-1.1.0}/src/pyrig_codeql/rig/configs/version_control/remote/workflows/health_check.py +8 -9
  7. {pyrig_codeql-1.0.2 → pyrig_codeql-1.1.0}/LICENSE +0 -0
  8. {pyrig_codeql-1.0.2 → pyrig_codeql-1.1.0}/src/pyrig_codeql/__init__.py +0 -0
  9. {pyrig_codeql-1.0.2 → pyrig_codeql-1.1.0}/src/pyrig_codeql/py.typed +0 -0
  10. {pyrig_codeql-1.0.2 → pyrig_codeql-1.1.0}/src/pyrig_codeql/rig/__init__.py +0 -0
  11. {pyrig_codeql-1.0.2 → pyrig_codeql-1.1.0}/src/pyrig_codeql/rig/configs/__init__.py +0 -0
  12. {pyrig_codeql-1.0.2 → pyrig_codeql-1.1.0}/src/pyrig_codeql/rig/configs/version_control/__init__.py +0 -0
  13. {pyrig_codeql-1.0.2 → pyrig_codeql-1.1.0}/src/pyrig_codeql/rig/configs/version_control/remote/__init__.py +0 -0
  14. {pyrig_codeql-1.0.2 → pyrig_codeql-1.1.0}/src/pyrig_codeql/rig/configs/version_control/remote/workflows/__init__.py +0 -0
  15. {pyrig_codeql-1.0.2 → pyrig_codeql-1.1.0}/src/pyrig_codeql/rig/resources/CODEQL_ANALYZE_ACTION +0 -0
  16. {pyrig_codeql-1.0.2 → pyrig_codeql-1.1.0}/src/pyrig_codeql/rig/resources/CODEQL_INIT_ACTION +0 -0
  17. {pyrig_codeql-1.0.2 → pyrig_codeql-1.1.0}/src/pyrig_codeql/rig/resources/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyrig-codeql
3
- Version: 1.0.2
3
+ Version: 1.1.0
4
4
  Summary: A pyrig plugin that integrates GitHub CodeQL.
5
5
  Keywords: pyrig
6
6
  Author: Winipedia
@@ -82,6 +82,8 @@ GitHub CodeQL analysis to your project's health-check workflow.
82
82
 
83
83
  - **CodeQL analysis** — analyzes Python and GitHub Actions code.
84
84
  - **Health-check integration** — adds CodeQL to the aggregate health-check gate.
85
+ - **Source-only analysis** — excludes the project's `tests/` directory from
86
+ CodeQL analysis.
85
87
 
86
88
  ## Usage
87
89
 
@@ -55,6 +55,8 @@ GitHub CodeQL analysis to your project's health-check workflow.
55
55
 
56
56
  - **CodeQL analysis** — analyzes Python and GitHub Actions code.
57
57
  - **Health-check integration** — adds CodeQL to the aggregate health-check gate.
58
+ - **Source-only analysis** — excludes the project's `tests/` directory from
59
+ CodeQL analysis.
58
60
 
59
61
  ## Usage
60
62
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "pyrig-codeql"
3
- version = "1.0.2"
3
+ version = "1.1.0"
4
4
  description = "A pyrig plugin that integrates GitHub CodeQL."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.12"
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "pyrig-codeql"
3
- version = "1.0.2"
3
+ version = "1.1.0"
4
4
  description = "A pyrig plugin that integrates GitHub CodeQL."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.12"
@@ -0,0 +1,40 @@
1
+ """CodeQL configuration that restricts analysis to shipped source code."""
2
+
3
+ from pathlib import Path
4
+ from typing import Any
5
+
6
+ from pyrig.rig.configs.base.yaml import YMLDictConfigFile
7
+ from pyrig.rig.tools.testing.project import ProjectTester
8
+ from pyrig.rig.tools.version_control.remote.controller import (
9
+ RemoteVersionController,
10
+ )
11
+
12
+
13
+ class CodeAnalyzerConfigFile(YMLDictConfigFile):
14
+ """Configuration consumed by the CodeQL `init` action's `config-file` input.
15
+
16
+ Manages `.github/codeql.yml`, including the query suite and ignored paths.
17
+ """
18
+
19
+ def parent_path(self) -> Path:
20
+ """Return GitHub's special repository configuration directory."""
21
+ return RemoteVersionController.I.config_dir()
22
+
23
+ def stem(self) -> str:
24
+ """Return `'codeql'`."""
25
+ return "codeql"
26
+
27
+ def _configs(self) -> dict[str, Any]:
28
+ """Build the CodeQL configuration.
29
+
30
+ Runs the `security-and-quality` query suite. Excludes the project's
31
+ test package, as determined by `ProjectTester.I.package_root()`, so
32
+ CodeQL scans shipped source code without test-only patterns.
33
+
34
+ Returns:
35
+ Dict with the codeql configurations.
36
+ """
37
+ return {
38
+ "paths-ignore": [f"{ProjectTester.I.package_root().as_posix()}/**"],
39
+ "queries": [{"uses": "security-and-quality"}],
40
+ }
@@ -8,6 +8,9 @@ from pyrig.rig.configs.version_control.remote.workflows.health_check import (
8
8
  )
9
9
 
10
10
  from pyrig_codeql.rig import resources
11
+ from pyrig_codeql.rig.configs.version_control.remote.code_analyzer import (
12
+ CodeAnalyzerConfigFile,
13
+ )
11
14
 
12
15
 
13
16
  class HealthCheckWorkflowConfigFile(BaseHealthCheckWorkflowConfigFile):
@@ -66,17 +69,14 @@ class HealthCheckWorkflowConfigFile(BaseHealthCheckWorkflowConfigFile):
66
69
  return [
67
70
  self.step_checkout_repository(),
68
71
  self.step_initialize_codeql(),
69
- self.step_perform_codeql_analysis(),
72
+ self.step_analyze_code(),
70
73
  ]
71
74
 
72
75
  def step_initialize_codeql(self) -> dict[str, Any]:
73
76
  """Build a step that initializes the CodeQL database.
74
77
 
75
78
  Neither analyzed language is compiled, so no build step is
76
- required between initialization and analysis. Runs the
77
- `security-and-quality` query suite, the strictest built-in suite,
78
- which is only available via advanced setup, not the default-setup
79
- API (whose `query_suite` field is limited to `default`/`extended`).
79
+ required between initialization and analysis.
80
80
 
81
81
  Returns:
82
82
  Step using `github/codeql-action/init@<ref>`.
@@ -86,12 +86,11 @@ class HealthCheckWorkflowConfigFile(BaseHealthCheckWorkflowConfigFile):
86
86
  uses=self.codeql_init_action(),
87
87
  with_={
88
88
  "languages": self.insert_expression("matrix.language"),
89
- "build-mode": "none",
90
- "queries": "security-and-quality",
89
+ "config-file": CodeAnalyzerConfigFile.I.path().as_posix(),
91
90
  },
92
91
  )
93
92
 
94
- def step_perform_codeql_analysis(self) -> dict[str, Any]:
93
+ def step_analyze_code(self) -> dict[str, Any]:
95
94
  """Build a step that runs the CodeQL analysis and uploads results.
96
95
 
97
96
  Fails the job if the analysis itself fails to run; code scanning
@@ -101,7 +100,7 @@ class HealthCheckWorkflowConfigFile(BaseHealthCheckWorkflowConfigFile):
101
100
  Step using `github/codeql-action/analyze@<ref>`.
102
101
  """
103
102
  return self.step(
104
- self.step_perform_codeql_analysis,
103
+ self.step_analyze_code,
105
104
  uses=self.codeql_analyze_action(),
106
105
  )
107
106
 
File without changes