Skip to content

Commit b108696

Browse files
authored
Fix IAST gRPC handler with null superclass (#8984)
1 parent 3a5c47b commit b108696

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

dd-java-agent/agent-iast/src/main/java/com/datadog/iast/GrpcRequestMessageHandler.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ public Flow<Void> apply(final RequestContext ctx, final Object o) {
4646
}
4747

4848
static boolean visitProtobufArtifact(@Nonnull final Class<?> kls) {
49-
if (kls.getSuperclass().getName().startsWith(GENERATED_MESSAGE)) {
49+
final Class<?> superClass = kls.getSuperclass();
50+
if (superClass != null && superClass.getName().startsWith(GENERATED_MESSAGE)) {
5051
return true; // GRPC custom messages
5152
}
5253
if (MAP_FIELD.equals(kls.getName())) {

dd-java-agent/agent-iast/src/test/groovy/com/datadog/iast/GrpcRequestMessageHandlerTest.groovy

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,14 @@ class GrpcRequestMessageHandlerTest extends IastModuleImplTestBase {
113113
buildProto3Message() | _
114114
}
115115

116+
void 'visitProtobufArtifact handles classes without superclass'() {
117+
when:
118+
boolean result = GrpcRequestMessageHandler.visitProtobufArtifact(Object)
119+
120+
then:
121+
!result
122+
}
123+
116124
private static def buildProto2Message() {
117125
final child = Test2.Proto2Child.newBuilder()
118126
.setOptional("optional")

0 commit comments

Comments
 (0)