Skip to content

Commit 1b70bf1

Browse files
committed
pylint updates, worklflows added, HANA RHEL attrs updated
1 parent c1c56d4 commit 1b70bf1

35 files changed

+871
-389
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-code-coverage.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
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+
# For Branch-Protection check. Only the default branch is supported. See
8+
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection
9+
branch_protection_rule:
10+
# To guarantee Maintained check is occasionally updated. See
11+
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained
12+
schedule:
13+
- cron: '32 4 * * 5'
14+
push:
15+
branches: [ "main" ]
16+
pull_request:
17+
branches: [ "main" ]
18+
19+
# Declare default permissions as read only.
20+
permissions: read-all
21+
22+
jobs:
23+
analysis:
24+
name: Scorecard analysis
25+
runs-on: ubuntu-latest
26+
permissions:
27+
# Needed to upload the results to code-scanning dashboard.
28+
security-events: write
29+
# Needed to publish results and get a badge (see publish_results below).
30+
id-token: write
31+
# Uncomment the permissions below if installing in a private repository.
32+
# contents: read
33+
# actions: readhttps://github.com/hdamecharla/sap-automation-kimforss/tree/main
34+
35+
steps:
36+
- name: Harden Runner
37+
uses: step-security/harden-runner@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.4
38+
with:
39+
egress-policy: audit
40+
41+
- name: "Checkout code"
42+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
43+
with:
44+
persist-credentials: false
45+
46+
- name: "Run analysis"
47+
uses: ossf/scorecard-action@62b2cac7ed8198b15735ed49ab1e5cf35480ba46 # v2.4.0
48+
with:
49+
results_file: results.sarif
50+
results_format: sarif
51+
# (Optional) "write" PAT token. Uncomment the `repo_token` line below if:
52+
# - you want to enable the Branch-Protection check on a *public* repository, or
53+
# - you are installing Scorecard on a *private* repository
54+
# repo_token: ${{ secrets.SCORECARD_TOKEN }}
55+
56+
# Public repositories:
57+
# - Publish results to OpenSSF REST API for easy access by consumers
58+
# - Allows the repository to include the Scorecard badge.
59+
# - See https://github.com/ossf/scorecard-action#publishing-results.
60+
# For private repositories:
61+
# - `publish_results` will always be set to `false`, regardless
62+
# of the value entered here.
63+
publish_results: true
64+
65+
# format to the repository Actions tab.
66+
- name: "Upload artifact"
67+
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
68+
with:
69+
name: SARIF file
70+
path: results.sarif
71+
retention-days: 5
72+
73+
# Upload the results to GitHub's code scanning dashboard (optional).
74+
# Commenting out will disable upload of results to your repo's Code Scanning dashboard
75+
- name: "Upload to code-scanning"
76+
uses: github/codeql-action/upload-sarif@d68b2d4edb4189fd2a5366ac14e72027bd4b37dd # v3.28.2
77+
with:
78+
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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ ptyprocess==0.7.0
4949
pycparser==2.22
5050
Pygments==2.19.1
5151
PyJWT==2.10.1
52+
pylint==2.12.2
5253
pytest==8.3.4
5354
pytest-cov==6.0.0
5455
pytest-mock==3.14.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]:

src/modules/check_indexserver.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,11 @@ def check_indexserver(self) -> None:
117117
"indexserver_enabled": "no",
118118
}
119119
)
120-
except Exception as e:
120+
except Exception as ex:
121121
self.result.update(
122122
{
123123
"status": TestStatus.ERROR.value,
124-
"message": f"Exception occurred while checking indexserver configuration: {e}",
124+
"message": f"Exception occurred while checking indexserver configuration: {ex}",
125125
"details": {},
126126
"indexserver_enabled": "no",
127127
}

0 commit comments

Comments
 (0)