Skip to content

Commit 3a46c18

Browse files
committed
pylint updates, worklflows added, HANA RHEL attrs updated
Add astroid dependency to requirements.txt Update py dependency versions and add new dependencies to requirements.txt Update Python version to 3.10 in GitHub Actions workflows Update GitHub Actions workflows to use latest actions and remove pull request trigger from OSSF scoreboard Update GitHub Actions workflows to use specific versions of actions and streamline permissions
1 parent c1c56d4 commit 3a46c18

36 files changed

+853
-391
lines changed

.github/workflows/codeql.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
#
12+
name: "CodeQL"
13+
14+
on:
15+
push:
16+
branches: ["main", "development"]
17+
pull_request:
18+
branches: ["main", "development"]
19+
schedule:
20+
- cron: "0 0 * * 1"
21+
22+
permissions:
23+
contents: read
24+
25+
jobs:
26+
analyze:
27+
name: Analyze
28+
runs-on: ubuntu-latest
29+
permissions:
30+
actions: read
31+
contents: read
32+
security-events: write
33+
34+
strategy:
35+
fail-fast: false
36+
matrix:
37+
language: ["javascript", "python"]
38+
39+
steps:
40+
- name: Harden Runner
41+
uses: step-security/harden-runner@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.4
42+
with:
43+
egress-policy: audit
44+
45+
- name: Checkout repository
46+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
47+
48+
- name: Initialize CodeQL
49+
uses: github/codeql-action/init@d68b2d4edb4189fd2a5366ac14e72027bd4b37dd # v3.28.2
50+
with:
51+
languages: ${{ matrix.language }}
52+
53+
- name: Autobuild
54+
uses: github/codeql-action/autobuild@d68b2d4edb4189fd2a5366ac14e72027bd4b37dd # v3.28.2
55+
56+
- name: Perform CodeQL Analysis
57+
uses: github/codeql-action/analyze@d68b2d4edb4189fd2a5366ac14e72027bd4b37dd # v3.28.2
58+
with:
59+
category: "/language:${{matrix.language}}"
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Dependency Review Action
2+
#
3+
# This Action will scan dependency manifest files that change as part of a Pull Request,
4+
# surfacing known-vulnerable versions of the packages declared or updated in the PR.
5+
# Once installed, if the workflow run is marked as required,
6+
# PRs introducing known-vulnerable packages will be blocked from merging.
7+
#
8+
# Source repository: https://github.com/actions/dependency-review-action
9+
name: 'Dependency Review'
10+
on: [pull_request]
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
dependency-review:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Harden Runner
20+
uses: step-security/harden-runner@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.4
21+
with:
22+
egress-policy: audit
23+
24+
- name: 'Checkout Repository'
25+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
26+
- name: 'Dependency Review'
27+
uses: actions/dependency-review-action@3b139cfc5fae8b618d3eae3675e383bb1769c019 # v4.5.0

.github/workflows/github-actions-ansible-lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- name: Setup Python
2020
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 #v5.4.0
2121
with:
22-
python-version: '3.x'
22+
python-version: '3.10'
2323

2424
- name: Install dependencies
2525
run: |

.github/workflows/github-actions-code-coverage.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- name: Setup Python
2020
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 #v5.4.0
2121
with:
22-
python-version: '3.x'
22+
python-version: '3.10'
2323

2424
- name: Install dependencies
2525
run: |
@@ -30,6 +30,10 @@ jobs:
3030
run: |
3131
pytest --cov=src/ --cov-fail-under=85 --cov-report=xml tests/
3232
33+
- name: Run pylint
34+
run: |
35+
pylint --load-plugins=pylint.extensions.docparams --fail-under=9 --disable=R $(git ls-files '*.py') --rcfile=./pyproject.toml
36+
3337
- name: Check code formatting with black
3438
run: |
3539
black --check src/ tests/ --config pyproject.toml
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# This workflow uses actions that are not certified by GitHub. They are provided
2+
# by a third-party and are governed by separate terms of service, privacy
3+
# policy, and support documentation.
4+
5+
name: Scorecard supply-chain security
6+
on:
7+
branch_protection_rule:
8+
schedule:
9+
- cron: '32 4 * * 5'
10+
push:
11+
branches: [ "main" ]
12+
13+
permissions: read-all
14+
15+
jobs:
16+
analysis:
17+
name: Scorecard analysis
18+
runs-on: ubuntu-latest
19+
permissions:
20+
security-events: write
21+
id-token: write
22+
23+
steps:
24+
- name: Harden Runner
25+
uses: step-security/harden-runner@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.4
26+
with:
27+
egress-policy: audit
28+
29+
- name: "Checkout code"
30+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
31+
with:
32+
persist-credentials: false
33+
34+
- name: "Run analysis"
35+
uses: ossf/scorecard-action@62b2cac7ed8198b15735ed49ab1e5cf35480ba46 # v2.4.0
36+
with:
37+
results_file: results.sarif
38+
results_format: sarif
39+
publish_results: true
40+
41+
- name: "Upload artifact"
42+
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
43+
with:
44+
name: SARIF file
45+
path: results.sarif
46+
retention-days: 5
47+
48+
- name: "Upload to code-scanning"
49+
uses: github/codeql-action/upload-sarif@d68b2d4edb4189fd2a5366ac14e72027bd4b37dd # v3.28.2
50+
with:
51+
sarif_file: results.sarif

.github/workflows/trivy.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
name: trivy
3+
4+
on:
5+
pull_request:
6+
types: [ 'opened', 'reopened', 'synchronize' ]
7+
merge_group:
8+
workflow_dispatch:
9+
10+
11+
permissions:
12+
actions: read
13+
contents: read
14+
security-events: write
15+
16+
jobs:
17+
build:
18+
name: 'trivy scan'
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Harden Runner
22+
uses: step-security/harden-runner@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.4
23+
with:
24+
egress-policy: audit
25+
26+
- name: Checkout code
27+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
28+
29+
- name: Run Trivy vulnerability scanner (file system)
30+
uses: aquasecurity/trivy-action@18f2510ee396bbf400402947b394f2dd8c87dbb0 # 0.29.0
31+
with:
32+
scan-type: 'fs'
33+
ignore-unfixed: true
34+
scan-ref: .
35+
format: 'sarif'
36+
scanners: 'vuln,secret,config'
37+
output: report-fs.sarif
38+
39+
- name: Upload Trivy report (fs) GitHub Security
40+
uses: github/codeql-action/upload-sarif@d68b2d4edb4189fd2a5366ac14e72027bd4b37dd # v3.28.2
41+
with:
42+
sarif_file: report-fs.sarif
43+
category: 'fs'

pyproject.toml

Lines changed: 53 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,43 +7,62 @@ load-plugins = ["pylint.extensions.docparams"]
77
[tool.pylint.basic]
88
argument-naming-style = "snake_case"
99
attr-naming-style = "snake_case"
10-
bad-names = ["foo", "bar", "baz", "toto", "tutu", "tata"]
1110
class-naming-style = "PascalCase"
12-
docstring-min-length = 10
1311
function-naming-style = "snake_case"
1412
variable-naming-style = "snake_case"
15-
13+
module-naming-style = "snake_case"
14+
bad-names = ["foo", "bar", "baz", "toto", "tutu", "tata"]
15+
docstring-min-length = 10
1616

1717
[tool.pylint.format]
1818
max-line-length = 100
1919
max-module-lines = 1000
2020

21+
[tool.pylint.docs]
22+
docstring-style = "sphinx"
23+
default-docstring-type = "sphinx"
24+
accept-no-param-doc = false
25+
accept-no-raise-doc = false
26+
accept-no-return-doc = false
27+
accept-no-yields-doc = false
28+
2129
[tool.pylint."messages control"]
2230
enable = [
23-
"C0116",
24-
"C0115",
25-
"C0114",
26-
"C0301",
27-
"E1101",
28-
"W0611",
31+
"missing-module-docstring",
32+
"missing-class-docstring",
33+
"wrong-exception-operation",
34+
"wrong-spelling-in-comment",
35+
"wrong-spelling-in-docstring",
36+
"missing-any-param-doc",
37+
"missing-format-attribute",
38+
"missing-kwoa",
39+
"missing-param-doc",
40+
"missing-parentheses-for-call-in-test",
41+
"missing-raises-doc",
42+
"missing-return-doc",
43+
"missing-return-type-doc",
44+
"missing-timeout",
45+
"missing-type-doc",
46+
"missing-yield-doc",
47+
"missing-yield-type-doc",
48+
"trailing-newlines",
49+
"trailing-whitespace",
2950
]
3051
disable = [
52+
"C0199", # empty-first-line-docstring
3153
"W0702", # bare-except
3254
"W0703", # broad-except
3355
"W4901", # global-statement
34-
"R0902", # too-many-instance-attributes
35-
"R0903", # too-few-public-methods
36-
"R1702",
37-
"R0801",
38-
"W0108"
56+
"W0108", # lambda
57+
"W0622", # redefined-builtin id
58+
"E0015",
59+
"E0401", # import-error
60+
"E0611", # no-name-in-module
3961
]
4062

4163
[tool.pylint.design]
4264
max-args = 5
4365

44-
[tool.pylint.docs]
45-
docstring-min-length = 10
46-
4766
[tool.pylint.variables]
4867
init-import = false
4968
dummy-variables-rgx = "_.*|dummy"
@@ -56,3 +75,20 @@ enable = [
5675
"E1101",
5776
"W0611",
5877
]
78+
79+
[tool.pylint.tests]
80+
disable = [
81+
"W0702", # bare-except
82+
"W0703", # broad-except
83+
"W4901", # global-statement
84+
"R0902", # too-many-instance-attributes
85+
"R0903", # too-few-public-methods
86+
"R1702", # too-many-nested-blocks
87+
"R0801", # duplicate-code
88+
"W0108", # lambda
89+
"E0401", # import-error
90+
"W0613", # unused-argument
91+
"W0212", # protected-access
92+
"W0107", # unnecessary-pass
93+
"C0103" # invalid-name
94+
]

requirements.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ ansible-compat==24.6.1
22
ansible-core==2.17.7
33
ansible-lint==24.6.1
44
ansible-runner==2.4.0
5+
astroid==2.9.0
56
attrs==25.1.0
67
azure-common==1.1.28
78
azure-core==1.32.0
@@ -27,13 +28,17 @@ ijson==3.3.0
2728
importlib_metadata==8.6.1
2829
iniconfig==2.0.0
2930
isodate==0.7.2
31+
isort==5.13.2
3032
Jinja2==3.1.6
3133
jsonschema==4.23.0
3234
jsonschema-specifications==2024.10.1
35+
lazy-object-proxy==1.10.0
3336
lockfile==0.12.2
3437
markdown-it-py==3.0.0
3538
MarkupSafe==3.0.2
39+
mccabe==0.6.1
3640
mdurl==0.1.2
41+
mock==5.1.0
3742
msal==1.31.1
3843
msal-extensions==1.2.0
3944
mypy-extensions==1.0.0
@@ -49,6 +54,7 @@ ptyprocess==0.7.0
4954
pycparser==2.22
5055
Pygments==2.19.1
5156
PyJWT==2.10.1
57+
pylint==2.12.2
5258
pytest==8.3.4
5359
pytest-cov==6.0.0
5460
pytest-mock==3.14.0
@@ -66,10 +72,12 @@ ruamel.yaml.clib==0.2.12
6672
six==1.17.0
6773
subprocess-tee==0.4.2
6874
tenacity==9.0.0
75+
toml==0.10.2
6976
tomli==2.2.1
7077
typing_extensions==4.12.2
7178
tzdata==2025.1
7279
urllib3==2.2.2
7380
wcmatch==10.0
81+
wrapt==1.13.3
7482
yamllint==1.35.1
7583
zipp==3.21.0

src/module_utils/get_cluster_status.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ def run(self) -> Dict[str, str]:
117117
self.result["message"] = "Pacemaker cluster isn't stable"
118118
self.log(logging.WARNING, self.result["message"])
119119

120-
except Exception as e:
121-
self.handle_error(e)
120+
except Exception as ex:
121+
self.handle_error(ex)
122122

123123
self.result["end"] = datetime.now()
124124
self.result["status"] = TestStatus.SUCCESS.value

src/module_utils/sap_automation_qa.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
and setup base variables for the test case running in the sap-automation-qa
44
"""
55

6-
import os
76
from abc import ABC
87
from enum import Enum
98
import sys
@@ -153,12 +152,12 @@ def execute_command_subprocess(self, command: str, shell_command: bool = False)
153152
stdout = command_output.stdout.decode("utf-8")
154153
stderr = command_output.stderr.decode("utf-8")
155154
return stdout if not stderr else stderr
156-
except subprocess.TimeoutExpired as e:
157-
self.handle_error(e, "Command timed out")
158-
except subprocess.CalledProcessError as e:
159-
self.handle_error(e, e.stderr.decode("utf-8").strip())
160-
except Exception as e:
161-
self.handle_error(e, "")
155+
except subprocess.TimeoutExpired as ex:
156+
self.handle_error(ex, "Command timed out")
157+
except subprocess.CalledProcessError as ex:
158+
self.handle_error(ex, ex.stderr.decode("utf-8").strip())
159+
except Exception as ex:
160+
self.handle_error(ex, "")
162161
return ""
163162

164163
def parse_xml_output(self, xml_output: str) -> Optional[ET.Element]:

0 commit comments

Comments
 (0)