Skip to content

Commit 653fcdf

Browse files
authored
Merge pull request #11 from tenable/fix/env-var-secret
Updated connector logging to unwind rich logging
2 parents 086a450 + 5d8c0f9 commit 653fcdf

File tree

4 files changed

+26
-10
lines changed

4 files changed

+26
-10
lines changed

tenint/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
from .models.configuration import Configuration, Settings # noqa F401
33
from .connector import Connector # noqa F401
44

5-
__version__ = "1.0.0"
5+
__version__ = "1.0.1"

tenint/connector.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,7 @@ def log_env_vars(self) -> None:
9595

9696
# Build the hidden list
9797
for cred in self.credentials:
98-
schema = cred.schema()
99-
for item, props in schema["properties"].items():
100-
if props.get("format") == "password":
101-
clean.append(f"{cred.prefix}_{item}".upper())
98+
clean += cred.env_secrets()
10299

103100
for key, value in os.environ.items():
104101
if key in clean:

tenint/models/credentials.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@ def definition(self) -> dict[str, Any]:
3333
@classmethod
3434
def env_secrets(cls) -> list[str]:
3535
resp = []
36-
schema = cls.schema()
36+
schema = cls.model_json_schema()
37+
prefix = cls.model_fields["prefix"].default
3738
for name, props in schema["properties"].items():
3839
if props.get("format") == "password":
39-
resp.append(f"{cls.prefix}_{name}".upper())
40+
resp.append(f"{prefix}_{name}".upper())
4041
return resp
4142

4243

@@ -59,9 +60,9 @@ class TenableSCCredential(Credential):
5960
Tenable Security Center Credential
6061
"""
6162

62-
prefix: Literal["tio"] = "tsc"
63+
prefix: Literal["tsc"] = "tsc"
6364
name: Literal["Tenable Security Center"] = "Tenable Security Center"
64-
slug: Literal["tvm"] = "tsc"
65+
slug: Literal["tsc"] = "tsc"
6566
description: str = "Tenable Security Center Credential"
6667
url: AnyHttpUrl
6768
access_key: str

tests/models/test_credentials.py

+19-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
from tenint.models.credentials import Credential
1+
from tenint.models.credentials import (
2+
Credential,
3+
TenableCloudCredential,
4+
TenableSCCredential,
5+
)
26

37

48
def test_base_credential_model():
@@ -47,3 +51,17 @@ class TestCredential(Credential):
4751
"title": "TestCredential",
4852
"type": "object",
4953
}
54+
55+
56+
def test_tenable_cloud_cred():
57+
assert TenableCloudCredential.model_fields["prefix"].default == "tio"
58+
assert TenableCloudCredential.model_fields["name"].default == "Tenable Cloud"
59+
assert TenableCloudCredential.model_fields["slug"].default == "tvm"
60+
assert TenableCloudCredential.env_secrets() == ["TIO_SECRET_KEY"]
61+
62+
63+
def test_tenable_sc_cred():
64+
assert TenableSCCredential.model_fields["prefix"].default == "tsc"
65+
assert TenableSCCredential.model_fields["name"].default == "Tenable Security Center"
66+
assert TenableSCCredential.model_fields["slug"].default == "tsc"
67+
assert TenableSCCredential.env_secrets() == ["TSC_SECRET_KEY"]

0 commit comments

Comments
 (0)