Skip to content

Commit 0fdeb81

Browse files
authored
Bugfix: no leaking sensitive data; handling AttributeError (#926)
Signed-off-by: Matthias Büchse <[email protected]>
1 parent cca8939 commit 0fdeb81

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

Tests/iaas/security-groups/default-security-group-rules.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,17 @@ def altern_test_rules(connection: openstack.connection.Connection):
108108
def test_rules(connection: openstack.connection.Connection):
109109
try:
110110
rules = list(connection.network.default_security_group_rules())
111-
except ResourceNotFound:
111+
except (ResourceNotFound, AttributeError) as exc:
112+
# older versions of OpenStack don't have the endpoint and give ResourceNotFound
113+
if isinstance(exc, ResourceNotFound) and 'default-security-group-rules' not in str(exc):
114+
raise
115+
# why we see the AttributeError in some environments is a mystery
116+
if isinstance(exc, AttributeError) and 'default_security_group_rules' not in str(exc):
117+
raise
112118
logger.info(
113119
"API call failed. OpenStack components might not be up to date. "
114120
"Falling back to old-style test method. "
115121
)
116-
logger.debug("traceback", exc_info=True)
117122
altern_test_rules(connection)
118123
else:
119124
check_default_rules(rules)
@@ -142,7 +147,7 @@ def main():
142147
"--debug", action="store_true", help="Enable debug logging",
143148
)
144149
args = parser.parse_args()
145-
openstack.enable_logging(debug=args.debug)
150+
openstack.enable_logging(debug=False) # never leak sensitive data (enable this locally)
146151
logging.basicConfig(
147152
format="%(levelname)s: %(message)s",
148153
level=logging.DEBUG if args.debug else logging.INFO,

0 commit comments

Comments
 (0)