Skip to content

Commit 0e41bae

Browse files
committed
Correct missing password hash removal
Auth has removal was broken in a number of cases for all 4.2 versions: - All queries that returned the object text for a mntner when all hash names (MD5-PW etc.) in the text were lower or mixed case - Queries for the auth attribute in GraphQL queries - Queries for the objectText for journal entries in GraphQL queries Further details in 4.2.3 release notes. Note that this commit only has the fix and tests or coverage may fail without the subsequent update to the tests.
1 parent c752ea5 commit 0e41bae

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

irrd/server/graphql/resolvers.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,8 @@ def resolve_rpsl_object_journal(rpsl_object, info: GraphQLResolveInfo):
187187
response['operation'] = response['operation'].name
188188
if response['origin']:
189189
response['origin'] = response['origin'].name
190+
if response['objectText']:
191+
response['objectText'] = remove_auth_hashes(response['objectText'])
190192
yield response
191193

192194

@@ -221,7 +223,7 @@ def _rpsl_db_query_to_graphql_out(query: RPSLDatabaseQuery, info: GraphQLResolve
221223
object_type = resolve_rpsl_object_type(row)
222224
for key, value in row.get('parsed_data', dict()).items():
223225
if key == 'auth':
224-
value = remove_auth_hashes(value)
226+
value = [remove_auth_hashes(v) for v in value]
225227
graphql_type = schema.graphql_types[object_type][key]
226228
if graphql_type == 'String' and isinstance(value, list):
227229
value = '\n'.join(value)

irrd/utils/text.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ def remove_auth_hashes(input: Optional[str]):
1212
if not input:
1313
return input
1414
# If there are no hashes, skip the RE for performance.
15-
if not any([pw_hash in input for pw_hash in PASSWORD_HASHERS_ALL.keys()]):
15+
input_lower = input.lower()
16+
if not any([pw_hash.lower() in input_lower for pw_hash in PASSWORD_HASHERS_ALL.keys()]):
1617
return input
1718
return re_remove_passwords.sub(r'\1 %s # Filtered for security' % PASSWORD_HASH_DUMMY_VALUE, input)
1819

0 commit comments

Comments
 (0)