-
Notifications
You must be signed in to change notification settings - Fork 6k
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
[Java] Add support of 'x-obfuscated' property allowing for generated model classes an obfuscation of sensitive data (e.g. password) in toString() output (#2662) #7060
base: master
Are you sure you want to change the base?
Conversation
./bin/java-petstore-resttemplate.sh | ||
./bin/java-petstore-resttemplate-withxml.sh | ||
./bin/java-petstore-resteasy.sh | ||
./bin/java-petstore-google-api-client.sh |
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.
Moved these scripts to java-petstore-client-all.sh (all of them are clients).
Also added there retrofit2-play25 and vertx clients.
@@ -0,0 +1,48 @@ | |||
#!/bin/sh |
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.
Build clients generated by /bin/java-petstore-client-all.sh
@@ -0,0 +1,48 @@ | |||
#!/bin/sh |
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.
Build projects generated by /bin/java-petstore-server-all.sh
Does not include sbt-based java-play-framework* projects.
@@ -578,44 +607,7 @@ private void generateSupportingFiles(List<File> files, Map<String, Object> bundl | |||
} | |||
|
|||
if (ignoreProcessor.allowsFile(new File(outputFilename))) { | |||
if (templateFile.endsWith("mustache")) { |
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.
Moved into a separate method for reusing.
@@ -249,6 +251,28 @@ private void generateModelTests(List<File> files, Map<String, Object> models, St | |||
} | |||
} | |||
|
|||
/** |
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 method generates/copies "static" resources for model build. This is similar to "generateSupportingFiles", but "generateSupportingFiles" and "generateModelTests" are independent "phases".
Build with samples profile (-Psamples) fails on server/java-msf4j, and this is not related to the fix. |
Thanks for the PR but your commit (as shown in the Commits tab) is not linked to your Github account, which means this PR won't count as your contribution in https://github.com/swagger-api/swagger-codegen/graphs/contributors. Let me know if you need help fixing it. |
d65be9e
to
8cc8c1e
Compare
@wing328 Sorry for missing that. Fixed. |
@wing328 |
I've fixed that in the latest master. |
@SergeyLyakhov can you merge the latest |
@wing328 Merged latest origin/master into feature/x-obfuscated-java |
@SergeyLyakhov thanks. Let's see if all the tests pass. |
@wing328 >I've fixed that in the latest master. |
@wing328 Also other projects with errors (listed in the description section of PR) are still not built. Clients:
Servers:
|
This is an interesting PR. Is it still being worked on? |
This fix is completed, tested and covered by unit tests. |
Thank you!
|
@SergeyLyakhov I would appreciate if you can do (1) and (2) in a single PR based on the latest master. I'll do (3) and (4) later after merging the PR. |
@SergeyLyakhov please can you continue on this? I would love to see this in action. |
@smiklosovic |
Hello, is this feature by any chance still alive? Is there any possibility of a merge, or was it abandoned altogether? Thank you. |
Any chance for it? |
is there any work around to hide the sensitive field information ? |
hey, is there any solution to this problem already? |
Team, can we please get this PR merged? This would address a major security concern. |
PR checklist
[+] Read the contribution guidelines.
[+] Ran the shell script under
./bin/
to update Petstore sample so that CIs can verify the change. (For instance, only need to run./bin/{LANG}-petstore.sh
and./bin/security/{LANG}-petstore.sh
if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in.\bin\windows\
.[+] Filed the PR against the correct branch:
3.0.0
branch for changes related to OpenAPI spec 3.0. Default:master
.[+ ] Copied the technical committee to review the pull request if your PR is targeting a particular programming language.
@bbdouglas @JFCote @sreeshas @jfiala @lukoyanov @cbornet
Description of the PR
This change adds support of "x-obfuscated" [true|false] vendor extension property.
E.g.:
This will allow to exclude (obfuscate) sensitive data from toString() result for generated model class.
The following changes added:
1.1. changed pojo.mustache toString() to allow obfuscation of properties with "x-obfuscated: true" attribute;
1.2. added templates for model test generation: model_test.mustache pojo_test.mustache modelEnum_test.mustache. Where pojo_test.mustache contains testObfuscation_* junit method;
1.3. added util/ModelTestUtils.mustache utility class for model tests.
3.1 enabled model tests (model_test.mustache) generation for java-based languages.
3.2. added support for static resources for model test generation (util/ModelTestUtils.java).
P.S. There are few sample projects which are not built because of errors in its templates (not related to this change):
Clients:
Servers: