-
Notifications
You must be signed in to change notification settings - Fork 769
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
Added TransmitPreciseGeo activity handling in modules #3348
Conversation
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.
This looks good! Just left one very minor nitpick.
@@ -49,13 +55,45 @@ func TestHandleModuleActivitiesBidderRequestPayload(t *testing.T) { | |||
}}, | |||
}, | |||
}, | |||
|
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.
Nitpick: can you remove this blank line?
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 refactored func handleModuleActivities
the way you proposed to refactor similar function in analytics activities to reduce nesting.
hooks/hookexecution/executor.go
Outdated
@@ -68,6 +68,7 @@ func NewHookExecutor(builder hooks.ExecutionPlanBuilder, endpoint string, me met | |||
stageOutcomes: []StageOutcome{}, | |||
moduleContexts: &moduleContexts{ctxs: make(map[string]hookstage.ModuleContext)}, | |||
metricEngine: me, | |||
account: &config.Account{Privacy: config.AccountPrivacy{}}, |
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.
What's the motivation for creating an empty account here instead of just keeping it as nil
until an account is set on the hookExecutor
using SetAccount
? It seems like an attempt to avoid nil checks when executing each stage but I'm not sure that's a good idea.
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.
Addressed. I changed handleModuleActivities
function signature to accept account *config.Account
instead of AccountPrivacy.
hooks/hookexecution/executor_test.go
Outdated
@@ -760,7 +760,7 @@ func TestExecuteProcessedAuctionStage(t *testing.T) { | |||
{ | |||
description: "Stage execution can be rejected - and later hooks rejected", | |||
givenPlanBuilder: TestRejectPlanBuilder{}, | |||
givenAccount: nil, | |||
givenAccount: account, |
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.
We need to pass account here, because we want to test that BidRequest will not change even if we restrict activities: getModuleActivities("foo", false, false)
and payload for the hook will be modified.
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.
If we add the account nil check in handleModuleActivities
we shouldn't need to define an account here right? The way this test case is currently constructed, it seems like the only reason an account is being passed here now is to ensure PBS doesn't crash.
@@ -10,6 +10,12 @@ import ( | |||
"testing" | |||
) | |||
|
|||
const ( | |||
testIpv6 = "1111:2222:3333:4444:5555:6666:7777:8888" | |||
testIPv6Scubbed = "1111:2222::" |
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.
Super nitpick: typo Scrubbed
@@ -137,13 +206,27 @@ func TestHandleModuleActivitiesNoBidderRequestPayload(t *testing.T) { | |||
privacyConfig: getTransmitUFPDActivityConfig("foo", true), | |||
expectedPayloadData: hookstage.RawAuctionRequestPayload{}, | |||
}, | |||
{ | |||
description: "payload should change when transmitPreciseGeo is blocked by activity", |
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.
Some of the test cases in this test have descriptions that indicate the payload should change but it doesn't.
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.
Right, description fixed. Payload should NOT change in any of these cases, because hookstage.RawAuctionRequestPayload
doesn't implement hookstage.RequestUpdater
if !transmitUserFPDActivityAllowed { | ||
privacy.ScrubUserFPD(bidderReqCopy) | ||
} | ||
if !transmitPreciseGeoActivityAllowed { |
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.
In practice there should always be an account if we've gotten this far but perhaps we should add a check here to make sure the account is not nil just to be safe.
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.
Correct, in practice we will always have an account because we call hookExecutor.SetAccount(account)
in auction and amp_auction.
In order to add nil check for account, what do we expect to do if for some reason account is nil?
- skip activity execution:
privacy.ScrubGeoAndDeviceIP(bidderReqCopy, ipConf)
- set default masking values(which also should be already set) and execute activity with default values:
account.Privacy.IPv6Config.AnonKeepBits = iputil.IPv6DefaultMaskingBitSize
and
account.Privacy.IPv4Config.AnonKeepBits = iputil.IPv4DefaultMaskingBitSize
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 suggest option 2 so that we still scrub given the sensitive nature.
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.
Updated
hooks/hookexecution/executor_test.go
Outdated
@@ -699,7 +699,7 @@ func TestExecuteRawAuctionStage(t *testing.T) { | |||
|
|||
func TestExecuteProcessedAuctionStage(t *testing.T) { | |||
foobarModuleCtx := &moduleContexts{ctxs: map[string]hookstage.ModuleContext{"foobar": nil}} | |||
account := &config.Account{} | |||
account := &config.Account{Privacy: config.AccountPrivacy{}} |
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.
Nitpick: you shouldn't need to specify Privacy
because you're defining a zero value account which will create a nested zero value Privacy
object.
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.
Right, privacy is not a pointer. Removed.
hooks/hookexecution/executor_test.go
Outdated
@@ -760,7 +760,7 @@ func TestExecuteProcessedAuctionStage(t *testing.T) { | |||
{ | |||
description: "Stage execution can be rejected - and later hooks rejected", | |||
givenPlanBuilder: TestRejectPlanBuilder{}, | |||
givenAccount: nil, | |||
givenAccount: account, |
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.
If we add the account nil check in handleModuleActivities
we shouldn't need to define an account here right? The way this test case is currently constructed, it seems like the only reason an account is being passed here now is to ensure PBS doesn't crash.
Yes, it's needed for this test only. Do you think we may need to pass account with non-default values in future? |
@@ -699,7 +699,6 @@ func TestExecuteRawAuctionStage(t *testing.T) { | |||
|
|||
func TestExecuteProcessedAuctionStage(t *testing.T) { | |||
foobarModuleCtx := &moduleContexts{ctxs: map[string]hookstage.ModuleContext{"foobar": nil}} | |||
account := &config.Account{} |
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.
Do we want to remove this from every test in this file?
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 went through and tried removing all of these lines, and the tests still passed, so I think it can be removed.
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 agree with Alex; we can remove them.
No description provided.