Skip to content

Commit

Permalink
Refactor propagation module method names (DataDog#6945)
Browse files Browse the repository at this point in the history
  • Loading branch information
manuel-alvarez-alvarez authored Apr 30, 2024
1 parent 3293d86 commit d3eae46
Show file tree
Hide file tree
Showing 190 changed files with 847 additions and 798 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public NamedContextImpl(@Nonnull final PropagationModule module, @Nonnull final

@Override
public void taintValue(@Nullable final String value) {
module.taint(iastCtx(), value, source.getOrigin(), currentName, source.getValue());
module.taintString(iastCtx(), value, source.getOrigin(), currentName, source.getValue());
}

@Override
Expand All @@ -74,7 +74,7 @@ public void taintName(@Nullable final String name) {
// prevent tainting the same name more than once
if (currentName != name) {
currentName = name;
module.taint(iastCtx(), name, source.getOrigin(), name, source.getValue());
module.taintString(iastCtx(), name, source.getOrigin(), name, source.getValue());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class NamedContextTest extends DDSpecification {
context.taintName(name)

then:
1 * module.taint(_, name, source.origin, name, source.value)
1 * module.taintString(_, name, source.origin, name, source.value)

when:
context.taintName(name)
Expand All @@ -50,7 +50,7 @@ class NamedContextTest extends DDSpecification {
context.taintValue(value)

then:
1 * module.taint(_, value, source.origin, name, source.value)
1 * module.taintString(_, value, source.origin, name, source.value)
0 * _
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ public Flow<Void> apply(final RequestContext ctx, final Object o) {
final IastContext iastCtx = ctx.getData(RequestContextSlot.IAST);
final byte source = SourceTypes.GRPC_BODY;
final int tainted =
module.taintDeeply(iastCtx, o, source, GrpcRequestMessageHandler::isProtobufArtifact);
module.taintObjectDeeply(
iastCtx, o, source, GrpcRequestMessageHandler::isProtobufArtifact);
if (tainted > 0) {
IastMetricCollector.add(IastMetric.EXECUTED_SOURCE, source, tainted, iastCtx);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class FastCodecModule extends PropagationModuleImpl implements CodecModul
@Override
public void onUrlDecode(
@Nonnull final String value, @Nullable final String encoding, @Nonnull final String result) {
taintIfTainted(result, value);
taintStringIfTainted(result, value);
}

@Override
Expand All @@ -22,22 +22,22 @@ public void onStringFromBytes(
@Nullable final String charset,
@Nonnull final String result) {
// create a new range shifted to the result string coordinates
taintIfTainted(result, value, offset, length, false, NOT_MARKED);
taintStringIfRangeTainted(result, value, offset, length, false, NOT_MARKED);
}

@Override
public void onStringGetBytes(
@Nonnull final String value, @Nullable final String charset, @Nonnull final byte[] result) {
taintIfTainted(result, value);
taintObjectIfTainted(result, value);
}

@Override
public void onBase64Encode(@Nullable byte[] value, @Nullable byte[] result) {
taintIfTainted(result, value);
taintObjectIfTainted(result, value);
}

@Override
public void onBase64Decode(@Nullable byte[] value, @Nullable byte[] result) {
taintIfTainted(result, value);
taintObjectIfTainted(result, value);
}
}
Loading

0 comments on commit d3eae46

Please sign in to comment.