-
Notifications
You must be signed in to change notification settings - Fork 305
Enable API Security by default and make it lazy loading #9009
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,7 +86,7 @@ class GatewayBridgeSpecification extends DDSpecification { | |
|
||
TraceSegmentPostProcessor pp = Mock() | ||
ApiSecuritySamplerImpl requestSampler = Mock(ApiSecuritySamplerImpl) | ||
GatewayBridge bridge = new GatewayBridge(ig, eventDispatcher, requestSampler, [pp]) | ||
GatewayBridge bridge = new GatewayBridge(ig, eventDispatcher, () -> requestSampler, [pp]) | ||
|
||
Supplier<Flow<AppSecRequestContext>> requestStartedCB | ||
BiFunction<RequestContext, AgentSpan, Flow<Void>> requestEndedCB | ||
|
@@ -258,8 +258,9 @@ class GatewayBridgeSpecification extends DDSpecification { | |
ctx.data.rawURI = '/' | ||
ctx.data.peerAddress = '0.0.0.0' | ||
eventDispatcher.getDataSubscribers(_) >> nonEmptyDsInfo | ||
eventDispatcher.publishDataEvent(nonEmptyDsInfo, ctx.data, _ as DataBundle, _ as GatewayContext) >> | ||
{ bundle = it[2]; NoopFlow.INSTANCE } | ||
eventDispatcher.publishDataEvent(nonEmptyDsInfo, ctx.data, _ as DataBundle, _ as GatewayContext) >> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From here onwards, this is just spotless being funny. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let it have its fun then 😓 |
||
bundle = it[2]; NoopFlow.INSTANCE | ||
} | ||
|
||
and: | ||
reqHeadersDoneCB.apply(ctx) | ||
|
@@ -277,8 +278,9 @@ class GatewayBridgeSpecification extends DDSpecification { | |
|
||
when: | ||
eventDispatcher.getDataSubscribers(_) >> nonEmptyDsInfo | ||
eventDispatcher.publishDataEvent(nonEmptyDsInfo, ctx.data, _ as DataBundle, _ as GatewayContext) >> | ||
{ bundle = it[2]; gatewayContext = it[3]; NoopFlow.INSTANCE } | ||
eventDispatcher.publishDataEvent(nonEmptyDsInfo, ctx.data, _ as DataBundle, _ as GatewayContext) >> { | ||
bundle = it[2]; gatewayContext = it[3]; NoopFlow.INSTANCE | ||
} | ||
|
||
and: | ||
reqHeadersDoneCB.apply(ctx) | ||
|
@@ -298,8 +300,9 @@ class GatewayBridgeSpecification extends DDSpecification { | |
|
||
when: | ||
eventDispatcher.getDataSubscribers(_) >> nonEmptyDsInfo | ||
eventDispatcher.publishDataEvent(nonEmptyDsInfo, ctx.data, _ as DataBundle, _ as GatewayContext) >> | ||
{ bundle = it[2]; gatewayContext = it[3]; NoopFlow.INSTANCE } | ||
eventDispatcher.publishDataEvent(nonEmptyDsInfo, ctx.data, _ as DataBundle, _ as GatewayContext) >> { | ||
bundle = it[2]; gatewayContext = it[3]; NoopFlow.INSTANCE | ||
} | ||
|
||
and: | ||
reqHeadersDoneCB.apply(ctx) | ||
|
@@ -319,8 +322,9 @@ class GatewayBridgeSpecification extends DDSpecification { | |
|
||
when: | ||
eventDispatcher.getDataSubscribers(_) >> nonEmptyDsInfo | ||
eventDispatcher.publishDataEvent(nonEmptyDsInfo, ctx.data, _ as DataBundle, _ as GatewayContext) >> | ||
{ bundle = it[2]; gatewayContext = it[3]; NoopFlow.INSTANCE } | ||
eventDispatcher.publishDataEvent(nonEmptyDsInfo, ctx.data, _ as DataBundle, _ as GatewayContext) >> { | ||
bundle = it[2]; gatewayContext = it[3]; NoopFlow.INSTANCE | ||
} | ||
|
||
and: | ||
reqHeadersDoneCB.apply(ctx) | ||
|
@@ -339,9 +343,12 @@ class GatewayBridgeSpecification extends DDSpecification { | |
def adapter = TestURIDataAdapter.create(uri, supportsRaw) | ||
|
||
when: | ||
eventDispatcher.getDataSubscribers({ KnownAddresses.REQUEST_URI_RAW in it }) >> nonEmptyDsInfo | ||
eventDispatcher.publishDataEvent(nonEmptyDsInfo, ctx.data, _ as DataBundle, _ as GatewayContext) >> | ||
{ bundle = it[2]; gatewayContext = it[3]; NoopFlow.INSTANCE } | ||
eventDispatcher.getDataSubscribers({ | ||
KnownAddresses.REQUEST_URI_RAW in it | ||
}) >> nonEmptyDsInfo | ||
eventDispatcher.publishDataEvent(nonEmptyDsInfo, ctx.data, _ as DataBundle, _ as GatewayContext) >> { | ||
bundle = it[2]; gatewayContext = it[3]; NoopFlow.INSTANCE | ||
} | ||
|
||
and: | ||
requestMethodURICB.apply(ctx, 'GET', adapter) | ||
|
@@ -373,9 +380,12 @@ class GatewayBridgeSpecification extends DDSpecification { | |
def adapter = TestURIDataAdapter.create(uri) | ||
|
||
when: | ||
eventDispatcher.getDataSubscribers({ KnownAddresses.REQUEST_URI_RAW in it }) >> nonEmptyDsInfo | ||
eventDispatcher.publishDataEvent(nonEmptyDsInfo, ctx.data, _ as DataBundle, _ as GatewayContext) >> | ||
{ bundle = it[2]; gatewayContext = it[3]; NoopFlow.INSTANCE } | ||
eventDispatcher.getDataSubscribers({ | ||
KnownAddresses.REQUEST_URI_RAW in it | ||
}) >> nonEmptyDsInfo | ||
eventDispatcher.publishDataEvent(nonEmptyDsInfo, ctx.data, _ as DataBundle, _ as GatewayContext) >> { | ||
bundle = it[2]; gatewayContext = it[3]; NoopFlow.INSTANCE | ||
} | ||
|
||
and: | ||
requestMethodURICB.apply(ctx, 'GET', adapter) | ||
|
@@ -406,9 +416,12 @@ class GatewayBridgeSpecification extends DDSpecification { | |
GatewayContext gatewayContext | ||
|
||
when: | ||
eventDispatcher.getDataSubscribers({ KnownAddresses.REQUEST_PATH_PARAMS in it }) >> nonEmptyDsInfo | ||
eventDispatcher.publishDataEvent(nonEmptyDsInfo, ctx.data, _ as DataBundle, _ as GatewayContext) >> | ||
{ bundle = it[2]; gatewayContext = it[3]; NoopFlow.INSTANCE } | ||
eventDispatcher.getDataSubscribers({ | ||
KnownAddresses.REQUEST_PATH_PARAMS in it | ||
}) >> nonEmptyDsInfo | ||
eventDispatcher.publishDataEvent(nonEmptyDsInfo, ctx.data, _ as DataBundle, _ as GatewayContext) >> { | ||
bundle = it[2]; gatewayContext = it[3]; NoopFlow.INSTANCE | ||
} | ||
|
||
and: | ||
pathParamsCB.apply(ctx, [a: 'b']) | ||
|
@@ -663,9 +676,9 @@ class GatewayBridgeSpecification extends DDSpecification { | |
|
||
when: | ||
Flow<?> flow = requestBodyProcessedCB.apply(ctx, new Object() { | ||
@SuppressWarnings('UnusedPrivateField') | ||
private String foo = 'bar' | ||
}) | ||
@SuppressWarnings('UnusedPrivateField') | ||
private String foo = 'bar' | ||
}) | ||
|
||
then: | ||
1 * eventDispatcher.publishDataEvent(nonEmptyDsInfo, ctx.data, _ as DataBundle, _ as GatewayContext) >> | ||
|
@@ -762,9 +775,9 @@ class GatewayBridgeSpecification extends DDSpecification { | |
|
||
when: | ||
Flow<?> flow = grpcServerRequestMessageCB.apply(ctx, new Object() { | ||
@SuppressWarnings('UnusedPrivateField') | ||
private String foo = 'bar' | ||
}) | ||
@SuppressWarnings('UnusedPrivateField') | ||
private String foo = 'bar' | ||
}) | ||
|
||
then: | ||
1 * eventDispatcher.publishDataEvent(nonEmptyDsInfo, ctx.data, _ as DataBundle, _ as GatewayContext) >> | ||
|
@@ -919,28 +932,28 @@ class GatewayBridgeSpecification extends DDSpecification { | |
|
||
void 'no appsec events if was not created request context in request_start event'() { | ||
RequestContext emptyCtx = new RequestContext() { | ||
final Object data = null | ||
BlockResponseFunction blockResponseFunction | ||
|
||
@Override | ||
Object getData(RequestContextSlot slot) { | ||
data | ||
} | ||
|
||
@Override | ||
final TraceSegment getTraceSegment() { | ||
GatewayBridgeSpecification.this.traceSegment | ||
} | ||
|
||
@Override | ||
def <T> T getOrCreateMetaStructTop(String key, Function<String, T> defaultValue) { | ||
return null | ||
} | ||
|
||
@Override | ||
void close() throws IOException {} | ||
final Object data = null | ||
BlockResponseFunction blockResponseFunction | ||
|
||
@Override | ||
Object getData(RequestContextSlot slot) { | ||
data | ||
} | ||
|
||
@Override | ||
final TraceSegment getTraceSegment() { | ||
GatewayBridgeSpecification.this.traceSegment | ||
} | ||
|
||
@Override | ||
def <T> T getOrCreateMetaStructTop(String key, Function<String, T> defaultValue) { | ||
return null | ||
} | ||
|
||
@Override | ||
void close() throws IOException {} | ||
} | ||
|
||
StoredBodySupplier supplier = Stub() | ||
IGSpanInfo spanInfo = Stub(AgentSpan) | ||
Object obj = 'obj' | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correctly if I'm wrong, but this should also have a positive effect on span processing overhead when appsec is disabled right? (I'm asking because of the regressions in the high_load benchmarks, that might be spurious)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this should ensure that the post-processor is always no-op unless enabled.