Skip to content

ci: add SAST workflows (semgrep + bandit) with dep-pinned installs#920

Open
louiseschmidtgen wants to merge 1 commit into
mainfrom
KU-5612/sast-workflows
Open

ci: add SAST workflows (semgrep + bandit) with dep-pinned installs#920
louiseschmidtgen wants to merge 1 commit into
mainfrom
KU-5612/sast-workflows

Conversation

@louiseschmidtgen

Copy link
Copy Markdown
Contributor

Summary

Add static application security testing (SAST) workflows with hash-pinned pip dependencies, per the security team's recommendation that every repository implement SAST scanning.

Changes

Semgrep SAST workflow (.github/workflows/semgrep.yaml)

  • Runs p/python and p/github-actions rulesets on push/PR
  • Advisory-only: results uploaded to GitHub Security tab via SARIF

Bandit security scan (.github/workflows/bandit.yaml)

  • Scans Python code for common security anti-patterns
  • Blocks on HIGH severity only (-lll flag)
  • Runs on push/PR and weekly (Monday 09:00 UTC)

Dependency pinning (ci/requirements-*.{in,txt})

  • Pin semgrep and bandit pip installs with hash verification
  • Satisfies OSSF Scorecard Pinned-Dependencies checks for pip

Reference

@github-advanced-security

Copy link
Copy Markdown

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

@github-actions

github-actions Bot commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

Test results for commit 805d25d

Test coverage for 805d25d

Name                                            Stmts   Miss Branch BrPart  Cover   Missing
-------------------------------------------------------------------------------------------
charms/worker/k8s/src/certificates.py             187    187     44      0     0%   6-457
charms/worker/k8s/src/charm.py                    647    289    202     35    51%   120-121, 233-234, 244-245, 247, 261, 275-282, 305-310, 316-332, 369-372, 384, 393, 410-413, 418-420, 428-437, 460->465, 467-470, 504-505, 517->519, 524-526, 528-530, 542-556, 577, 585-591, 604-621, 637, 642-643, 653->exit, 675-691, 700-709, 721-733, 751-767, 777-792, 801-807, 819-861, 879-881, 883, 901-913, 922-949, 961-973, 983, 1025, 1028, 1037, 1047, 1050, 1060-1072, 1077-1083, 1105-1107, 1111-1114, 1125-1144, 1148-1149, 1169-1170, 1187, 1190-1191, 1197->1206, 1233-1236, 1239-1242, 1245-1248, 1254-1257, 1268-1269, 1272-1273
charms/worker/k8s/src/charmed_etcd.py              47     28      8      0    35%   32-36, 46, 57, 61-63, 67-81, 90-91, 95-102
charms/worker/k8s/src/cloud_integration.py         80      3     24      3    94%   140, 149->151, 158-159
charms/worker/k8s/src/config/arg_files.py          78      0     22      2    98%   125->124, 143->141
charms/worker/k8s/src/config/bootstrap.py         145     24     54      5    78%   65-84, 158-159, 202-203, 205, 223, 252, 266->254
charms/worker/k8s/src/config/cluster.py            63      3     22     11    84%   37, 51->53, 59->61, 63->65, 66, 68, 73->75, 79->81, 85->87, 92->94, 98->100
charms/worker/k8s/src/config/extra_args.py         41      3     18      3    90%   32->27, 79, 97, 113
charms/worker/k8s/src/config/option.py             20      0      8      0   100%
charms/worker/k8s/src/config/resource.py           33      7      4      1    73%   32, 57-58, 63-72
charms/worker/k8s/src/containerd.py               154     15     48     18    83%   45-48, 78->82, 82->85, 85->88, 234->236, 240->243, 243->245, 245->247, 247->250, 262, 269, 276, 327-328, 340-341, 355, 357, 359, 363
charms/worker/k8s/src/cos_integration.py           41     16      4      0    56%   82, 117-234, 238
charms/worker/k8s/src/endpoints.py                 40      1     18      1    97%   62
charms/worker/k8s/src/events/update_status.py     104     19     32      9    78%   93, 99-100, 124, 126, 142, 156-167, 173, 191, 192->194, 198
charms/worker/k8s/src/inspector.py                 62     10     24      6    79%   44-45, 74, 109, 122-123, 132, 138-143
charms/worker/k8s/src/k8s/client.py                20      4      2      1    77%   39->41, 47-48, 50-51
charms/worker/k8s/src/k8s/node.py                  34     14      4      0    53%   47-49, 52, 65-75
charms/worker/k8s/src/k8sd_api_manager.py         408     27     14      2    93%   701, 776-777, 1008, 1051-1053, 1062-1066, 1128, 1197, 1205, 1223, 1236-1237, 1298-1300, 1311-1314, 1331-1335
charms/worker/k8s/src/kube_control.py              44     32     10      0    22%   31-35, 44-90
charms/worker/k8s/src/literals.py                 109      0      0      0   100%
charms/worker/k8s/src/pki.py                       29      9      2      1    68%   35-36, 49-54, 65
charms/worker/k8s/src/protocols.py                 33      5      0      0    85%   60, 68, 76, 84, 92
charms/worker/k8s/src/reschedule.py                79      4      6      3    92%   155->158, 174-175, 191-192, 215->exit, 221->exit
charms/worker/k8s/src/snap.py                     180     16     58     11    89%   110, 188-189, 200-201, 214->207, 232-237, 291-292, 294, 297->288, 304->288, 308, 329-330
charms/worker/k8s/src/token_distributor.py        251    129     66      7    43%   112-114, 128, 182, 186, 211, 236->exit, 267, 287-288, 301-311, 332, 348-361, 407->406, 411, 415->420, 438-472, 506, 519, 529, 550-660, 679-732, 745-747
charms/worker/k8s/src/upgrade.py                  121     38     36      5    64%   81-108, 191->193, 202-205, 208-212, 219->221, 222-225, 242
charms/worker/k8s/src/utils.py                     16     16      4      0     0%   6-47
-------------------------------------------------------------------------------------------
TOTAL                                            3066    899    734    124    66%

Static code analysis report

Run started:2026-04-09 06:59:50.296483+00:00

Test results:
  No issues identified.

Code scanned:
  Total lines of code: 6144
  Total lines skipped (#nosec): 4
  Total potential issues skipped due to specifically being disabled (e.g., #nosec BXXX): 0

Run metrics:
  Total issues (by severity):
  	Undefined: 0
  	Low: 0
  	Medium: 0
  	High: 0
  Total issues (by confidence):
  	Undefined: 0
  	Low: 0
  	Medium: 0
  	High: 0
Files skipped (0):

@github-actions

github-actions Bot commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

Test results for commit 805d25d

Test coverage for 805d25d

Name                                            Stmts   Miss Branch BrPart  Cover   Missing
-------------------------------------------------------------------------------------------
charms/worker/k8s/src/certificates.py             187    187     44      0     0%   6-457
charms/worker/k8s/src/charm.py                    647    289    202     35    51%   120-121, 233-234, 244-245, 247, 261, 275-282, 305-310, 316-332, 369-372, 384, 393, 410-413, 418-420, 428-437, 460->465, 467-470, 504-505, 517->519, 524-526, 528-530, 542-556, 577, 585-591, 604-621, 637, 642-643, 653->exit, 675-691, 700-709, 721-733, 751-767, 777-792, 801-807, 819-861, 879-881, 883, 901-913, 922-949, 961-973, 983, 1025, 1028, 1037, 1047, 1050, 1060-1072, 1077-1083, 1105-1107, 1111-1114, 1125-1144, 1148-1149, 1169-1170, 1187, 1190-1191, 1197->1206, 1233-1236, 1239-1242, 1245-1248, 1254-1257, 1268-1269, 1272-1273
charms/worker/k8s/src/charmed_etcd.py              47     28      8      0    35%   32-36, 46, 57, 61-63, 67-81, 90-91, 95-102
charms/worker/k8s/src/cloud_integration.py         80      3     24      3    94%   140, 149->151, 158-159
charms/worker/k8s/src/config/arg_files.py          78      0     22      2    98%   125->124, 143->141
charms/worker/k8s/src/config/bootstrap.py         145     24     54      5    78%   65-84, 158-159, 202-203, 205, 223, 252, 266->254
charms/worker/k8s/src/config/cluster.py            63      3     22     11    84%   37, 51->53, 59->61, 63->65, 66, 68, 73->75, 79->81, 85->87, 92->94, 98->100
charms/worker/k8s/src/config/extra_args.py         41      3     18      3    90%   32->27, 79, 97, 113
charms/worker/k8s/src/config/option.py             20      0      8      0   100%
charms/worker/k8s/src/config/resource.py           33      7      4      1    73%   32, 57-58, 63-72
charms/worker/k8s/src/containerd.py               154     15     48     18    83%   45-48, 78->82, 82->85, 85->88, 234->236, 240->243, 243->245, 245->247, 247->250, 262, 269, 276, 327-328, 340-341, 355, 357, 359, 363
charms/worker/k8s/src/cos_integration.py           41     16      4      0    56%   82, 117-234, 238
charms/worker/k8s/src/endpoints.py                 40      1     18      1    97%   62
charms/worker/k8s/src/events/update_status.py     104     19     32      9    78%   93, 99-100, 124, 126, 142, 156-167, 173, 191, 192->194, 198
charms/worker/k8s/src/inspector.py                 62     10     24      6    79%   44-45, 74, 109, 122-123, 132, 138-143
charms/worker/k8s/src/k8s/client.py                20      4      2      1    77%   39->41, 47-48, 50-51
charms/worker/k8s/src/k8s/node.py                  34     14      4      0    53%   47-49, 52, 65-75
charms/worker/k8s/src/k8sd_api_manager.py         408     27     14      2    93%   701, 776-777, 1008, 1051-1053, 1062-1066, 1128, 1197, 1205, 1223, 1236-1237, 1298-1300, 1311-1314, 1331-1335
charms/worker/k8s/src/kube_control.py              44     32     10      0    22%   31-35, 44-90
charms/worker/k8s/src/literals.py                 109      0      0      0   100%
charms/worker/k8s/src/pki.py                       29      9      2      1    68%   35-36, 49-54, 65
charms/worker/k8s/src/protocols.py                 33      5      0      0    85%   60, 68, 76, 84, 92
charms/worker/k8s/src/reschedule.py                79      4      6      3    92%   155->158, 174-175, 191-192, 215->exit, 221->exit
charms/worker/k8s/src/snap.py                     180     16     58     11    89%   110, 188-189, 200-201, 214->207, 232-237, 291-292, 294, 297->288, 304->288, 308, 329-330
charms/worker/k8s/src/token_distributor.py        251    129     66      7    43%   112-114, 128, 182, 186, 211, 236->exit, 267, 287-288, 301-311, 332, 348-361, 407->406, 411, 415->420, 438-472, 506, 519, 529, 550-660, 679-732, 745-747
charms/worker/k8s/src/upgrade.py                  121     38     36      5    64%   81-108, 191->193, 202-205, 208-212, 219->221, 222-225, 242
charms/worker/k8s/src/utils.py                     16     16      4      0     0%   6-47
-------------------------------------------------------------------------------------------
TOTAL                                            3066    899    734    124    66%

Static code analysis report

Run started:2026-04-09 06:59:58.220980+00:00

Test results:
  No issues identified.

Code scanned:
  Total lines of code: 6144
  Total lines skipped (#nosec): 4
  Total potential issues skipped due to specifically being disabled (e.g., #nosec BXXX): 0

Run metrics:
  Total issues (by severity):
  	Undefined: 0
  	Low: 0
  	Medium: 0
  	High: 0
  Total issues (by confidence):
  	Undefined: 0
  	Low: 0
  	Medium: 0
  	High: 0
Files skipped (0):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants