Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ public static ResultList<Query> getQueries(
}

private static boolean hasPiiSensitiveTag(Query query) {
return query.getTags().stream().map(TagLabel::getTagFQN).anyMatch(SENSITIVE_PII_TAG::equals);
return query.getTags() != null && query.getTags().stream().map(TagLabel::getTagFQN).anyMatch(SENSITIVE_PII_TAG::equals);
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Outdated
}

private static boolean hasPiiSensitiveTag(Column column) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,34 @@ void getQueriesAndMaskUserHideSensitiveValuesForUnauthorizedUsers() {
assertEquals(PIIMasker.MASKED_MAIL, maskedUser.getEmail());
}

@Test
void getQueriesHandlesNullTagsForUnauthorizedUsers() {
Authorizer authorizer = mock(Authorizer.class);
SecurityContext securityContext = mock(SecurityContext.class);

EntityReference owner = entityReference(Entity.USER, "owner");

Query query =
new Query()
.withQuery("select email from customer")
.withOwners(List.of(owner));

query.setTags(null);

ResultList<Query> queries =
new ResultList<>(new ArrayList<>(List.of(query)));

when(authorizer.authorizePII(securityContext, List.of(owner)))
.thenReturn(false);

ResultList<Query> result =
PIIMasker.getQueries(queries, authorizer, securityContext);

assertEquals(
"select email from customer",
result.getData().get(0).getQuery());
}

@Test
void getQueriesAndMaskUserLeaveAuthorizedValuesUntouched() {
Authorizer authorizer = mock(Authorizer.class);
Expand Down
Loading