bitwarden_workflow_linter 0.14.3__py3-none-any.whl → 0.14.5__py3-none-any.whl
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.
- bitwarden_workflow_linter/__about__.py +1 -1
- bitwarden_workflow_linter/default_settings.yaml +1 -0
- bitwarden_workflow_linter/models/job.py +2 -0
- bitwarden_workflow_linter/rules/check_pr_target.py +6 -10
- bitwarden_workflow_linter/rules/permissions_exist.py +11 -4
- bitwarden_workflow_linter/utils.py +8 -1
- {bitwarden_workflow_linter-0.14.3.dist-info → bitwarden_workflow_linter-0.14.5.dist-info}/METADATA +1 -1
- {bitwarden_workflow_linter-0.14.3.dist-info → bitwarden_workflow_linter-0.14.5.dist-info}/RECORD +11 -11
- {bitwarden_workflow_linter-0.14.3.dist-info → bitwarden_workflow_linter-0.14.5.dist-info}/WHEEL +0 -0
- {bitwarden_workflow_linter-0.14.3.dist-info → bitwarden_workflow_linter-0.14.5.dist-info}/entry_points.txt +0 -0
- {bitwarden_workflow_linter-0.14.3.dist-info → bitwarden_workflow_linter-0.14.5.dist-info}/licenses/LICENSE.txt +0 -0
@@ -32,6 +32,7 @@ class Job:
|
|
32
32
|
metadata=config(field_name="with"), default=None
|
33
33
|
)
|
34
34
|
outputs: Optional[CommentedMap] = None
|
35
|
+
permissions: Optional[object] = None # This can be a CommentedMap or a string
|
35
36
|
|
36
37
|
@classmethod
|
37
38
|
def parse_needs(cls: Self, value):
|
@@ -50,6 +51,7 @@ class Job:
|
|
50
51
|
"env": data["env"] if "env" in data else None,
|
51
52
|
"needs": Job.parse_needs(data["needs"]) if "needs" in data else None,
|
52
53
|
"outputs": data["outputs"] if "outputs" in data else None,
|
54
|
+
"permissions": data["permissions"] if "permissions" in data else None,
|
53
55
|
}
|
54
56
|
|
55
57
|
new_job = cls.from_dict(init_data)
|
@@ -27,16 +27,12 @@ class RuleCheckPrTarget(Rule):
|
|
27
27
|
self.compatibility = [Workflow]
|
28
28
|
self.settings = settings
|
29
29
|
|
30
|
-
def targets_main_branch(self, obj:Workflow) -> bool:
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
return False
|
37
|
-
else:
|
38
|
-
return False
|
39
|
-
return True
|
30
|
+
def targets_main_branch(self, obj: Workflow) -> bool:
|
31
|
+
default_branch = self.settings.default_branch
|
32
|
+
branches = obj.on["pull_request_target"].get("branches", [])
|
33
|
+
if isinstance(branches, str):
|
34
|
+
branches = [branches]
|
35
|
+
return len(branches) == 1 and branches[0] == default_branch
|
40
36
|
|
41
37
|
def has_check_run(self, obj: Workflow) -> Tuple[bool, str]:
|
42
38
|
for name, job in obj.jobs.items():
|
@@ -3,6 +3,7 @@
|
|
3
3
|
from typing import Optional, Tuple
|
4
4
|
|
5
5
|
from ..models.workflow import Workflow
|
6
|
+
from ..models.job import Job
|
6
7
|
from ..rule import Rule
|
7
8
|
from ..utils import LintLevels, Settings
|
8
9
|
|
@@ -26,18 +27,24 @@ class RulePermissionsExist(Rule):
|
|
26
27
|
lint_level: Optional[LintLevels] = LintLevels.NONE,
|
27
28
|
) -> None:
|
28
29
|
self.message = (
|
29
|
-
"
|
30
|
+
"All workflows must specify permissions on either workflow or job level"
|
30
31
|
)
|
31
32
|
self.on_fail = lint_level
|
32
33
|
self.compatibility = [Workflow]
|
33
34
|
self.settings = settings
|
34
35
|
|
35
|
-
def
|
36
|
-
if
|
36
|
+
def permissions_exist_on_workflow(self, workflow: Workflow) -> bool:
|
37
|
+
if workflow.permissions is None:
|
37
38
|
return False
|
38
39
|
return True
|
39
40
|
|
41
|
+
def permissions_exist_on_jobs(self, jobs: list[Job]) -> bool:
|
42
|
+
for job in jobs:
|
43
|
+
if job.permissions is None:
|
44
|
+
return False
|
45
|
+
return True
|
46
|
+
|
40
47
|
def fn(self, obj: Workflow) -> Tuple[bool, str]:
|
41
|
-
if not self.
|
48
|
+
if not self.permissions_exist_on_workflow(obj) and not self.permissions_exist_on_jobs(obj.jobs.values()):
|
42
49
|
return False, f"{self.message}"
|
43
50
|
return True, ""
|
@@ -113,12 +113,14 @@ class Settings:
|
|
113
113
|
enabled_rules: list[dict[str, str]]
|
114
114
|
approved_actions: dict[str, Action]
|
115
115
|
actionlint_version: str
|
116
|
+
default_branch: Optional[str]
|
116
117
|
|
117
118
|
def __init__(
|
118
119
|
self,
|
119
120
|
enabled_rules: Optional[list[dict[str, str]]] = None,
|
120
121
|
approved_actions: Optional[dict[str, dict[str, str]]] = None,
|
121
122
|
actionlint_version: Optional[str] = None,
|
123
|
+
default_branch: Optional[str] = None,
|
122
124
|
) -> None:
|
123
125
|
"""Settings object that can be overridden in settings.py.
|
124
126
|
|
@@ -144,6 +146,7 @@ class Settings:
|
|
144
146
|
self.approved_actions = {
|
145
147
|
name: Action(**action) for name, action in approved_actions.items()
|
146
148
|
}
|
149
|
+
self.default_branch = default_branch
|
147
150
|
|
148
151
|
@staticmethod
|
149
152
|
def factory() -> SettingsFromFactory:
|
@@ -189,9 +192,13 @@ class Settings:
|
|
189
192
|
) as action_file:
|
190
193
|
settings["approved_actions"] = json.load(action_file)
|
191
194
|
|
192
|
-
|
195
|
+
default_branch = settings.get("default_branch")
|
196
|
+
if default_branch is None or len(default_branch) == 0:
|
197
|
+
raise Exception("The default_branch is not set in the default_settings.yaml file")
|
198
|
+
|
193
199
|
return Settings(
|
194
200
|
enabled_rules=settings["enabled_rules"],
|
195
201
|
approved_actions=settings["approved_actions"],
|
196
202
|
actionlint_version=actionlint_version,
|
203
|
+
default_branch=default_branch,
|
197
204
|
)
|
{bitwarden_workflow_linter-0.14.3.dist-info → bitwarden_workflow_linter-0.14.5.dist-info}/METADATA
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: bitwarden_workflow_linter
|
3
|
-
Version: 0.14.
|
3
|
+
Version: 0.14.5
|
4
4
|
Summary: Custom GitHub Action Workflow Linter
|
5
5
|
Project-URL: Homepage, https://github.com/bitwarden/workflow-linter
|
6
6
|
Project-URL: Issues, https://github.com/bitwarden/workflow-linter/issues
|
{bitwarden_workflow_linter-0.14.3.dist-info → bitwarden_workflow_linter-0.14.5.dist-info}/RECORD
RENAMED
@@ -1,31 +1,31 @@
|
|
1
|
-
bitwarden_workflow_linter/__about__.py,sha256=
|
1
|
+
bitwarden_workflow_linter/__about__.py,sha256=2-qa0YjKWSCy2VJpGQ8Oyle8DLLT03zz8T-bUmc9qFI,60
|
2
2
|
bitwarden_workflow_linter/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
3
|
bitwarden_workflow_linter/actionlint_version.yaml,sha256=CKhiDwaDBNCExOHTlcpiavfEgf01uG_tTPrgLRaj6_k,28
|
4
4
|
bitwarden_workflow_linter/actions.py,sha256=LAn3yQeMMmCOvJWeTn3dE1U2nyEJqIBMwESq3TtY9hE,9069
|
5
5
|
bitwarden_workflow_linter/cli.py,sha256=wgkK1MlVbo6Zx3f2CZZ_tkSWq_hdsGciHJA1knX6Yuw,1699
|
6
6
|
bitwarden_workflow_linter/default_actions.json,sha256=gfnuWVJwBOnig50x4YTUcrseaxaOVGyFDcYfQVK6Two,13650
|
7
|
-
bitwarden_workflow_linter/default_settings.yaml,sha256=
|
7
|
+
bitwarden_workflow_linter/default_settings.yaml,sha256=EoIQVnZ_WXzoaMyXQjtcNatIXRey2HSfe2ROUlyvSwg,1065
|
8
8
|
bitwarden_workflow_linter/lint.py,sha256=R0dXkwir0KzXFHWfWlqpH_CyBwa7O8wHSBTy560u94g,6322
|
9
9
|
bitwarden_workflow_linter/load.py,sha256=FWxotIlB0vyKzrVw87sOx3qdRiJG_0hVHRbbLXZY4Sc,5553
|
10
10
|
bitwarden_workflow_linter/rule.py,sha256=Qb60JiUDAWN3ayrMGoSbbDCSFmw-ql8djzAkxISaob4,3250
|
11
|
-
bitwarden_workflow_linter/utils.py,sha256=
|
11
|
+
bitwarden_workflow_linter/utils.py,sha256=KV2Vo-hhNVRWOiIq_y-55li-noMt9F-FFgkJK-nUKJo,5823
|
12
12
|
bitwarden_workflow_linter/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
13
|
-
bitwarden_workflow_linter/models/job.py,sha256=
|
13
|
+
bitwarden_workflow_linter/models/job.py,sha256=oqFq8A4JGQplBlaDjUUFV9kWT5rh9A0V6FYGf0IaGg0,2553
|
14
14
|
bitwarden_workflow_linter/models/step.py,sha256=j81iWYWcNI9x55n1MOR0N6ogKaQ_4-CKu9LnI_fwEOE,1814
|
15
15
|
bitwarden_workflow_linter/models/workflow.py,sha256=lIgGI2cDwC2lTOM-k3fqKgceLdSJ6vhTLCAhaeoD-fc,1645
|
16
16
|
bitwarden_workflow_linter/rules/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
17
|
-
bitwarden_workflow_linter/rules/check_pr_target.py,sha256=
|
17
|
+
bitwarden_workflow_linter/rules/check_pr_target.py,sha256=lleDloCukjRAI0d54Ne8-yVMw9aNEqB5pGb9cNBuC8k,3430
|
18
18
|
bitwarden_workflow_linter/rules/job_environment_prefix.py,sha256=bdE8l4B5DQiCFVmblXTs4ptsHPGvjhJrR5ONo2kRY2U,2757
|
19
19
|
bitwarden_workflow_linter/rules/name_capitalized.py,sha256=lGHPi_Ix0DVSzGEdrUm2vAEQD4qQ8dxU1hddsCdqA2w,2126
|
20
20
|
bitwarden_workflow_linter/rules/name_exists.py,sha256=kdMIURN3u8qdDvw6YKxg7VF5bkzGxVVXAO3KAqY1-54,1826
|
21
|
-
bitwarden_workflow_linter/rules/permissions_exist.py,sha256=
|
21
|
+
bitwarden_workflow_linter/rules/permissions_exist.py,sha256=vjqyNF9il73JHlvKKlb9vzZ_g4LEPNKOO4-4OnHGCQ8,1737
|
22
22
|
bitwarden_workflow_linter/rules/pinned_job_runner.py,sha256=VPQfMu3SgIFdl-B8wOXzzK6tMx2hWWSJbKL5KG3xcaI,1751
|
23
23
|
bitwarden_workflow_linter/rules/run_actionlint.py,sha256=m6SaejtkUz704exAiq_ti0d1a0wtDBb7QJE0EsFINv4,4712
|
24
24
|
bitwarden_workflow_linter/rules/step_approved.py,sha256=4pUCrOlWomo43bwGBunORphv1RJzc3spRKgZ4VLtDS0,3304
|
25
25
|
bitwarden_workflow_linter/rules/step_pinned.py,sha256=MagV8LNdgRKyncmSdH9V-TlIcsdjzoDHDWqovzWon9E,3559
|
26
26
|
bitwarden_workflow_linter/rules/underscore_outputs.py,sha256=LoCsDN_EfQ8H9n5BfZ5xCe7BeHqJGPMcV0vo1c9YJcw,4275
|
27
|
-
bitwarden_workflow_linter-0.14.
|
28
|
-
bitwarden_workflow_linter-0.14.
|
29
|
-
bitwarden_workflow_linter-0.14.
|
30
|
-
bitwarden_workflow_linter-0.14.
|
31
|
-
bitwarden_workflow_linter-0.14.
|
27
|
+
bitwarden_workflow_linter-0.14.5.dist-info/METADATA,sha256=zzLK5AYnhzG9jd9U62TztYNHmt1vPEXTW4Z0M9DDRbo,9797
|
28
|
+
bitwarden_workflow_linter-0.14.5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
29
|
+
bitwarden_workflow_linter-0.14.5.dist-info/entry_points.txt,sha256=SA_yF9CwL4VMUvdcmCd7k9rjsQNzfeOUBuDnMnaO8QQ,60
|
30
|
+
bitwarden_workflow_linter-0.14.5.dist-info/licenses/LICENSE.txt,sha256=uY-7N9tbI7xc_c0WeTIGpacSCnsB91N05eCIg3bkaRw,35140
|
31
|
+
bitwarden_workflow_linter-0.14.5.dist-info/RECORD,,
|
{bitwarden_workflow_linter-0.14.3.dist-info → bitwarden_workflow_linter-0.14.5.dist-info}/WHEEL
RENAMED
File without changes
|
File without changes
|
File without changes
|