Skip to content

Commit

Permalink
Update gitleaks configuration in mega-linter
Browse files Browse the repository at this point in the history
- Make `gitleaks` only check the current PR
- Add comments in `test_*.py` to make `gitleaks` ignore the test user data

Signed-off-by: Joe Block <[email protected]>
  • Loading branch information
unixorn committed Jan 1, 2024
1 parent 339de21 commit f8b717a
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 56 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/mega-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,12 @@ jobs:
- name: Lint Code Base
uses: oxsecurity/megalinter/flavors/python@v7
env:
DOCKERFILE_HADOLINT_DISABLE_ERRORS: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PAT: ${{secrets.PAT}}
REPOSITORY_GITLEAKS_PR_COMMITS_SCAN: true
REPOSITORY_TRIVY_DISABLE_ERRORS: true
DOCKERFILE_HADOLINT_DISABLE_ERRORS: true
VALIDATE_ALL_CODEBASE: false

# Upload Mega-Linter artifacts.
# They will be available on Github action page "Artifacts" section
Expand Down
104 changes: 54 additions & 50 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions tests/test_discoverable.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
def discoverable() -> Discoverable[EntityInfo]:
mqtt_settings = Settings.MQTT(
host="localhost", username="admin", password="password"
)
) # gitleaks:allow
sensor_info = EntityInfo(name="test", component="binary_sensor")
settings = Settings(mqtt=mqtt_settings, entity=sensor_info)
return Discoverable[EntityInfo](settings)
Expand All @@ -48,7 +48,7 @@ def discoverable_availability() -> Discoverable[EntityInfo]:
"""Return an instance of Discoverable configured with `manual_availability`"""
mqtt_settings = Settings.MQTT(
host="localhost", username="admin", password="password"
)
) # gitleaks:allow
sensor_info = EntityInfo(name="test", component="binary_sensor")
settings = Settings(
mqtt=mqtt_settings, entity=sensor_info, manual_availability=True
Expand Down Expand Up @@ -206,7 +206,7 @@ def test_device_with_unique_id():
def test_name_with_space():
mqtt_settings = Settings.MQTT(
host="localhost", username="admin", password="password"
)
) # gitleaks:allow
sensor_info = EntityInfo(name="Name with space", component="binary_sensor")
settings = Settings(mqtt=mqtt_settings, entity=sensor_info)
d = Discoverable[EntityInfo](settings)
Expand All @@ -216,7 +216,7 @@ def test_name_with_space():
def test_custom_object_id():
mqtt_settings = Settings.MQTT(
host="localhost", username="admin", password="password"
)
) # gitleaks:allow
sensor_info = EntityInfo(
name="Test name", component="binary_sensor", object_id="custom object id"
)
Expand Down Expand Up @@ -303,7 +303,7 @@ def test_disconnect_client(mocker: MockerFixture):
mock_instance.connect.return_value = MQTT_ERR_SUCCESS
mqtt_settings = Settings.MQTT(
host="localhost", username="admin", password="password"
)
) # gitleaks:allow
sensor_info = EntityInfo(name="test", component="binary_sensor")
settings = Settings(mqtt=mqtt_settings, entity=sensor_info)

Expand Down

0 comments on commit f8b717a

Please sign in to comment.