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

Skip code generation of data filter functions for shapes that do not contain sensitive fields (recursive) #722

Merged
merged 10 commits into from
Mar 22, 2023

Conversation

kuhe
Copy link
Contributor

@kuhe kuhe commented Mar 17, 2023

Adds a recursive check for sensitive fields before generating a sensitive data filter function.
Currently all input/output have their own function even if it does nothing. This removes the no-op functions to reduce the code size.

For diff in JSv3 as an example, see aws/aws-sdk-js-v3#4544
(first commit contains a single client for easier viewing).

@kuhe kuhe force-pushed the feat/data-filter branch 4 times, most recently from b837e38 to ff59244 Compare March 20, 2023 19:54
@kuhe kuhe marked this pull request as ready for review March 20, 2023 19:58
@kuhe kuhe requested review from a team as code owners March 20, 2023 19:58
@kuhe kuhe changed the title check for sensitive data before generating a filter function Skip code generation of data filter functions for shapes that do not contain sensitive fields (recursive) Mar 20, 2023
* @param model - model context for the shape, containing its related shapes.
* @return whether a sensitive field exists in the shape and its downstream shapes.
*/
public boolean findsSensitiveData(Shape shape, Model model) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method name is a little confusing. Maybe containsSensitiveData instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't want to use contains because the subject of the method is not a container like the collections that typically use that method name. How about findsSensitiveDataIn for the phrase finder.findsSensitiveDataIn(shape)?

* a given shape.
*/
public class SensitiveDataFinder {
private Map<Shape, Boolean> cache = new HashMap<>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this cache supposed to work? The public method takes in a model, which could change. I don't think this will work as expected, unless the same model is used every time.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the model to be a constructor parameter.

@kuhe kuhe merged commit e2325f6 into smithy-lang:main Mar 22, 2023
@kuhe kuhe deleted the feat/data-filter branch March 22, 2023 22:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants