-
Notifications
You must be signed in to change notification settings - Fork 394
[APPSEC-8112] Appsec block request when user ID matches rules data #2642
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# typed: false | ||
# frozen_string_literal: true | ||
|
||
module Datadog | ||
module AppSec | ||
module Ext | ||
INTERRUPT = :datadog_appsec_interrupt | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
# typed: false | ||
# frozen_string_literal: true | ||
|
||
require_relative '../../ext' | ||
require_relative '../../instrumentation/gateway' | ||
require_relative '../../reactive/operation' | ||
require_relative '../reactive/set_user' | ||
|
@@ -48,7 +49,7 @@ def watch_user_id(gateway = Instrumentation.gateway) | |
_result, block = Monitor::Reactive::SetUser.publish(op, user) | ||
end | ||
|
||
next [nil, [[:block, event]]] if block | ||
throw(Datadog::AppSec::Ext::INTERRUPT, [nil, [:block, event]]) if block | ||
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. As mentioned in other discussions, we will have to see if this is still correct when multiple watchers are present on the same watch point. 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. Absolutely. 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. I'm eager to have a use case for multiple watchers and see how the reactive engine works |
||
|
||
ret, res = stack.call(user) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,6 +56,11 @@ def self.set_user(trace, id:, email: nil, name: nil, session_id: nil, role: nil, | |
others.each do |k, v| | ||
trace.set_tag("usr.#{k}", v) unless v.nil? | ||
end | ||
|
||
if Datadog.configuration.appsec.enabled | ||
user = OpenStruct.new(id: id) | ||
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. 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.
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. Absolutely. I'm not a fun of |
||
::Datadog::AppSec::Instrumentation.gateway.push('identity.set_user', user) | ||
end | ||
end | ||
# rubocop:enable Metrics/PerceivedComplexity | ||
# rubocop:enable Metrics/CyclomaticComplexity | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module Datadog | ||
module AppSec | ||
module Ext | ||
INTERRUPT: Symbol | ||
end | ||
end | ||
end |
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.
I guess you genericised the name from
REQUEST_INTERRUPT
toINTERRUPT
so that it's context agnostic (request or otherwise)?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.
Exactly. Would you like to change it? I thought about
BLOCK
which is also context agnostic