Skip to content
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

[Unified Recorder] Features #15829

Closed
83 of 97 tasks
HarshaNalluru opened this issue Jun 17, 2021 · 5 comments
Closed
83 of 97 tasks

[Unified Recorder] Features #15829

HarshaNalluru opened this issue Jun 17, 2021 · 5 comments
Assignees
Labels
EngSys This issue is impacting the engineering system. Epic test-utils-recorder Label for the issues related to the common recorder
Milestone

Comments

@HarshaNalluru
Copy link
Member

HarshaNalluru commented Jun 17, 2021

Background

Bare minimum prototype with storage blob client (underlying core-http) #15826 node test.

Beyond the investigations and issues encountered so far in building a primitive prototype, a lot more needs to be done, following is the list of features that are required before we can attempt migrating the SDKs.

Features / Bugs to fix

Resources

@ghost ghost added the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Jun 17, 2021
@HarshaNalluru HarshaNalluru self-assigned this Jun 17, 2021
@HarshaNalluru HarshaNalluru added the test-utils-recorder Label for the issues related to the common recorder label Jun 17, 2021
@ghost ghost removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Jun 17, 2021
@scbedd
Copy link
Member

scbedd commented Jun 17, 2021

Hey @HarshaNalluru ! Thanks for the details!

Couple comments!

Current prototype installs, runs and stops the docker container manually, we need a script to make it black box and run when the test script is triggered

Will have this for ya very soon. Messing about with permissions on our ACR to make it truely anonymous access.

Proxy tool should support regex replacements

We absolutely support this for header/URI quite well. I will finish updating the README with a whole bunch of detail and examples and forward it to ya. Should have that for you later today.

Proxy tool should support plain string replacements

Same as above.

uuids can be randomly generated within the SDK which makes the requests dynamic in playback, so customizing outgoing requests should be supported

Which test can I work against to repro? I've got an early version of this already implemented, but don't want to put you through debugging it against a docker container :P

Access tokens need to be masked automatically before saving the recordings

Should already be there, let's chat about where it's not happening!

After a brief discussion, I'll use the branch feature/unified-recorder to repro issues as soon as it's present on the azure-sdk-for-js repo.

For any questions I have that require additional detail, I'll send you a teams meeting request! Thanks!

@HarshaNalluru
Copy link
Member Author

uuids can be randomly generated within the SDK which makes the requests dynamic in playback, so customizing outgoing requests should be supported
Which test can I work against to repro? I've got an early version of this already implemented, but don't want to put you through debugging it against a docker container :P

Assume a test generates a uuid, the saved request has a different uuid from what will be the request during playback. So, this needs customization of the request in playback with a regex of sorts.

Access tokens need to be masked automatically before saving the recordings
Should already be there, let's chat about where it's not happening!

Sure, I just logged this issue with all the details so they are being traked somewhere, I'll strikeoff one-by-one as I test them. :)

After a brief discussion, I'll use the branch feature/unified-recorder to repro issues as soon as it's present on the azure-sdk-for-js repo.

The PR #15826 isn't merged yet, feature branch can be used once that is merged. Until then, the only way would be to use my branch.

@scbedd
Copy link
Member

scbedd commented Jun 21, 2021

Output of our discussion on 6/21.

Recorder should pass the test path to the proxy tool to be able to save the recording at the desired location

Sitting on this one given the new startup scripts.

Recorder(and proxy tool) should allow tweaking the request bodies or paths(customizing outgoing requests) during playback

Need to think about this more. The test pr has exact context for example.

Access tokens need to be masked automatically before saving the recordings

This is done.

Additional q not in set above. Need to ensure ContinuationSanitizer works appropriately. I will work through an example. Pass me an exact test I can work through. Here is an example recording

Scope sanitization to be allowed to remove false positives from cred scan

The bodies of the responses have a string that's NOT a secret, but still trips credscan. Here's an example. Check for scope argument.. Write a sanitizer to clean it up.

Recordings have a lot of headers that can be dynamic, could be better if they are stripped out or updated with defaults

I will add a RemoveHeader sanitizer. You call it before your test run.

Allow tweaking the recording for the end user programmatically

Use a transform or a sanitizer.

Filing issues for:

  • OS Compiled Executable
  • Add RemoveHeader Sanitizer
  • ScopeURL request body replacement <-- this fits well into BodyRegexSanitizer implementation.
  • MSAL Ignores body matching on specific request only. Not on all request/responses within a recording.

@scbedd
Copy link
Member

scbedd commented Jul 7, 2021

Hey @HarshaNalluru, got some updates for ya.

General Discussion and Advice

To begin, you don't need to install a specific tag of the docker image anymore. Use the latest tag when accessing the docker image. Additionally,
local builds are perfectly functional now.

When you're running in live mode, before any tests invoke, ensure that you hit up the Admin/AddSanitizer to add appropriate sanitization.

I believe there should be a base set or what-have-you that should be present generically, with the ability to add specific items for your service requirements.

In Python, I'd handle this with a session level fixture, with additional customization provided as part of test configuration per specific service.

For all of the below examples, feel free to hit /Info/Available for additional detail. I also have unit tests that exercise these sanitizers
if you need an example of the actual regex as well. I used your scope replacement for one of them.

Random TableNames, other resources that are randomly generated.

I did give some thought to your original question WRT the whole:

Table name is randomly generated, so we retrieve what the last random name from the recording prior to invoking the test.

I don't really think there is a way to do this with a remote server. At least, not one that would be performant. I think the better way to do this is one of two options

  1. During record, add a sanitizer that updates stuff like table name (or whatever else is randomized) to a understood "filler". So table1249 changes to targettable. During playback mode, if you activate that same sanitizer, the incoming request will be sanitized to the same table name value and match the recording.
  2. During record, use the same sanitizer as in Initial commit for copying files from azure-sdk-for-node #1, and just directly use those filler values when you're running in playback.
  3. (As of yet uncoded), we create a generalized matcher that just ignores certain fields when matching your request.

Of course, I'm open to further feedback and discussion here.

Remove-Header Sanitizer

This one is pretty straightforward, pass along a comma separated list of key or keys for headers that you want gone from the saved recording.

POST
url: <proxyURL>/Admin/AddSanitizer
headers: {
    "x-abstraction-identifier": "BodyRegexSanitizer"
}
body: {
    "headersForRemoval": "Location,<your-other-header>",
}

Spaces are trimmed, so you don't need to worry about whitespace around the commas. You also aren't limited to a single one of these, so you could add multiple Remove-Header that each removes one. It's really up to you.

Body-Key Sanitizer

Use this sanitizer if you want to update a specific member w/ a regex or whole value replace. The document string in /Info/Available does link here, but the documentation for available search through your body is documented here

POST
url: <proxyURL>/Admin/AddSanitizer
headers: {
    "x-abstraction-identifier": "BodyKeySanitizer"
}
body: {
    "value": "<your-new-value>",
    "regex": ".*",
    "jsonPath": "$.TableName"
}

Note that the above example is just a "complete" replacement. You can do a scoped replacement just like I have for the BodyRegex example.

Body Regex Sanitizer

Use this sanitizer if you aren't dealing with a JSON body. It does free-text regex replace. Your scope replacement ask is an example of when you'd use this boyo.

POST
url: <proxyURL>/Admin/AddSanitizer
headers: {
    "x-abstraction-identifier": "BodyRegexSanitizer"
}
body: {
    "value": "<your-new-value>",
    "regex": "scope\\=(?<scope>[^&]*)",
    "groupForReplace": "scope"
}

In Summary

I believe the above should meet the vast majority of the needs you have. I have a ContinuationToken written up, but before I ask you to use that, I'd prefer to eat the bullet on debugging the inevitable issues :)

Additionally, I believe that providing an superceding sanitizer that does URI, Body, and HEAD regex replacement with the same regex may be useful, but that's not present currently. LMK what you think about this one.

I expect more issues will arise as this get's coded into real tests, but I'll tackle those when they occur. Easiest way to get through it is to hit the failure.

@HarshaNalluru HarshaNalluru added this to the [2022] February milestone Jan 3, 2022
@HarshaNalluru HarshaNalluru modified the milestones: [2022] May, [2022] June May 10, 2022
@HarshaNalluru HarshaNalluru modified the milestones: [2022] June, [2022] July Jun 7, 2022
@xirzec xirzec modified the milestones: 2022-07, 2022-08 Jul 8, 2022
@xirzec xirzec modified the milestones: 2022-08, 2022-09 Aug 9, 2022
@HarshaNalluru HarshaNalluru modified the milestones: 2022-09, 2022-10 Sep 8, 2022
@HarshaNalluru HarshaNalluru modified the milestones: 2022-10, 2022-11 Oct 31, 2022
@HarshaNalluru HarshaNalluru modified the milestones: 2022-11, 2022-12 Nov 11, 2022
@xirzec xirzec modified the milestones: 2022-12, 2023-02 Jan 11, 2023
@HarshaNalluru HarshaNalluru modified the milestones: 2023-02, 2023-03 Feb 7, 2023
@HarshaNalluru HarshaNalluru modified the milestones: 2023-03, 2023-04 Feb 28, 2023
Copy link

Hi @HarshaNalluru, we deeply appreciate your input into this project. Regrettably, this issue has remained inactive for over 2 years, leading us to the decision to close it. We've implemented this policy to maintain the relevance of our issue queue and facilitate easier navigation for new contributors. If you still believe this topic requires attention, please feel free to create a new issue, referencing this one. Thank you for your understanding and ongoing support.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Mar 15, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Mar 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
EngSys This issue is impacting the engineering system. Epic test-utils-recorder Label for the issues related to the common recorder
Projects
None yet
Development

No branches or pull requests

4 participants