Skip to content

Commit 512b725

Browse files
authored
Merge pull request #50 from cibere/bandit
Update Workflows + Bandit Changes
2 parents b301cce + ec36878 commit 512b725

File tree

6 files changed

+53
-30
lines changed

6 files changed

+53
-30
lines changed

.github/workflows/build.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ jobs:
1111
strategy:
1212
fail-fast: false
1313
matrix:
14-
python-version: [ '3.11', '3.12', '3.13' ]
14+
python-version: ${{ fromJson(vars.PYTHON_VERSIONS) }}
1515

1616
name: docs on ${{ matrix.python-version }}
1717
steps:
18-
- uses: actions/checkout@v3
18+
- uses: actions/checkout@v4
1919
with:
2020
fetch-depth: 0
2121

2222
- name: Set up CPython ${{ matrix.python-version }}
23-
uses: actions/setup-python@v4
23+
uses: actions/setup-python@v5
2424
with:
2525
python-version: ${{ matrix.python-version }}
2626

@@ -39,16 +39,16 @@ jobs:
3939
strategy:
4040
fail-fast: false
4141
matrix:
42-
python-version: [ '3.11', '3.12', '3.13' ]
42+
python-version: ${{ fromJson(vars.PYTHON_VERSIONS) }}
4343

4444
name: dist on ${{ matrix.python-version }}
4545
steps:
46-
- uses: actions/checkout@v3
46+
- uses: actions/checkout@v4
4747
with:
4848
fetch-depth: 0
4949

5050
- name: Set up CPython ${{ matrix.python-version }}
51-
uses: actions/setup-python@v4
51+
uses: actions/setup-python@v5
5252
with:
5353
python-version: ${{ matrix.python-version }}
5454

.github/workflows/format.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ jobs:
1111
strategy:
1212
fail-fast: false
1313
matrix:
14-
python-version: [ '3.11', '3.12', '3.13' ]
14+
python-version: ${{ fromJson(vars.PYTHON_VERSIONS) }}
1515

1616
name: Black on ${{ matrix.python-version }}
1717
steps:
18-
- uses: actions/checkout@v3
18+
- uses: actions/checkout@v4
1919
with:
2020
fetch-depth: 0
2121

2222
- name: Set up CPython ${{ matrix.python-version }}
23-
uses: actions/setup-python@v4
23+
uses: actions/setup-python@v5
2424
with:
2525
python-version: ${{ matrix.python-version }}
2626

@@ -40,16 +40,16 @@ jobs:
4040
strategy:
4141
fail-fast: false
4242
matrix:
43-
python-version: [ '3.11', '3.12', '3.13' ]
43+
python-version: ${{ fromJson(vars.PYTHON_VERSIONS) }}
4444

4545
name: Ruff on ${{ matrix.python-version }}
4646
steps:
47-
- uses: actions/checkout@v3
47+
- uses: actions/checkout@v4
4848
with:
4949
fetch-depth: 0
5050

5151
- name: Set up CPython ${{ matrix.python-version }}
52-
uses: actions/setup-python@v4
52+
uses: actions/setup-python@v5
5353
with:
5454
python-version: ${{ matrix.python-version }}
5555

.github/workflows/lint.yml

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ jobs:
1111
strategy:
1212
fail-fast: false
1313
matrix:
14-
python-version: [ '3.11', '3.12', '3.13' ]
14+
python-version: ${{ fromJson(vars.PYTHON_VERSIONS) }}
1515

1616
name: Pyright on ${{ matrix.python-version }}
1717
steps:
18-
- uses: actions/checkout@v3
18+
- uses: actions/checkout@v4
1919
with:
2020
fetch-depth: 0
2121

2222
- name: Set up CPython ${{ matrix.python-version }}
23-
uses: actions/setup-python@v4
23+
uses: actions/setup-python@v5
2424
with:
2525
python-version: ${{ matrix.python-version }}
2626

@@ -41,16 +41,16 @@ jobs:
4141
strategy:
4242
fail-fast: false
4343
matrix:
44-
python-version: [ '3.11', '3.12', '3.13' ]
44+
python-version: ${{ fromJson(vars.PYTHON_VERSIONS) }}
4545

4646
name: Ruff on ${{ matrix.python-version }}
4747
steps:
48-
- uses: actions/checkout@v3
48+
- uses: actions/checkout@v4
4949
with:
5050
fetch-depth: 0
5151

5252
- name: Set up CPython ${{ matrix.python-version }}
53-
uses: actions/setup-python@v4
53+
uses: actions/setup-python@v5
5454
with:
5555
python-version: ${{ matrix.python-version }}
5656

@@ -62,4 +62,33 @@ jobs:
6262
6363
- name: Run Ruff Linter
6464
if: ${{ always() && steps.install-deps.outcome == 'success' }}
65-
uses: astral-sh/ruff-action@v3
65+
uses: astral-sh/ruff-action@v3
66+
67+
bandit:
68+
runs-on: ubuntu-latest
69+
strategy:
70+
fail-fast: false
71+
matrix:
72+
python-version: ${{ fromJson(vars.PYTHON_VERSIONS) }}
73+
74+
name: Bandit on ${{ matrix.python-version }}
75+
steps:
76+
- uses: actions/checkout@v4
77+
with:
78+
fetch-depth: 0
79+
80+
- name: Set up CPython ${{ matrix.python-version }}
81+
uses: actions/setup-python@v5
82+
with:
83+
python-version: ${{ matrix.python-version }}
84+
85+
- name: Install dependencies
86+
id: install-deps
87+
run: |
88+
pip install .[tests]
89+
pip install bandit
90+
91+
- name: Run Bandit
92+
run: |
93+
bandit -c pyproject.toml -r flogin
94+
bandit -c pyproject.toml -r tests --skip B101

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
strategy:
1212
fail-fast: false
1313
matrix:
14-
python-version: [ '3.11', '3.12', '3.13' ]
14+
python-version: ${{ fromJson(vars.PYTHON_VERSIONS) }}
1515

1616
name: check ${{ matrix.python-version }}
1717
steps:

flogin/jsonrpc/results.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import annotations
22

33
import logging
4-
import random
4+
import secrets
55
from typing import (
66
TYPE_CHECKING,
77
Any,
@@ -437,11 +437,7 @@ def create_with_partial(
437437

438438
@cached_property
439439
def slug(self) -> str:
440-
return "".join(
441-
random.choices(
442-
"QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm1234567890", k=15
443-
)
444-
)
440+
return secrets.token_hex(15)
445441

446442
def __repr__(self) -> str:
447443
return f"<{self.__class__.__name__} {self.title=} {self.sub=} {self.icon=} {self.title_highlight_data=} {self.title_tooltip=} {self.sub_tooltip=} {self.copy_text=} {self.score=} {self.auto_complete_text=} {self.preview=} {self.progress_bar=} {self.rounded_icon=} {self.glyph=}>"

flogin/testing/plugin_tester.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import json
44
import os
5-
import random
65
import sys
76
import uuid
87
from typing import TYPE_CHECKING, Any, Generic
@@ -81,7 +80,6 @@ def __init__(
8180
)
8281
with open("plugin.json") as f:
8382
metadata = json.load(f)
84-
assert metadata
8583

8684
if isinstance(metadata, dict):
8785
metadata = PluginMetadata(metadata, self.plugin.api)
@@ -216,8 +214,8 @@ def create_bogus_plugin_metadata(cls: type[PluginTester]) -> PluginMetadata:
216214

217215
return cls.create_plugin_metadata(
218216
id=str(uuid.uuid4()),
219-
name="".join(random.choices(CHARACTERS, k=10)),
220-
author="".join(random.choices(CHARACTERS, k=5)),
217+
name="Test Plugin",
218+
author="flogin",
221219
version="1.0.0",
222220
description="A plugin with bogus metadata to test",
223221
)

0 commit comments

Comments
 (0)