-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Serializing changes for sensitive data #5655
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
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
9d70665
Add new senstiive data serializer
tadgh 2fe2185
Add new senstiive data serializer
tadgh 94ef3ef
Add new senstiive data serializer
tadgh 232107d
Remove dead comments
tadgh 9aced6d
Change up the test
tadgh c5b9daa
review comments
tadgh 3b15cbc
wip
tadgh 47e2306
Tighten tests and push annotation down
tadgh 6e842f9
Tighten tests and push annotation down
tadgh 8ccc3a8
Changelog
tadgh 5a5eab3
Add test
tadgh 2c80635
7.0.1-SNAPSHOT bump
tadgh c428aa9
Error code
tadgh 8cc616c
Add method used by CDR
tadgh d1f62d2
add version enum
tadgh 802dc35
Fix test
tadgh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/annotation/SensitiveNoDisplay.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/*- | ||
* #%L | ||
* HAPI FHIR - Core Library | ||
* %% | ||
* Copyright (C) 2014 - 2024 Smile CDR, Inc. | ||
* %% | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* #L% | ||
*/ | ||
package ca.uhn.fhir.model.api.annotation; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* Annotation to mark a field as sensitive, indicating that it should not | ||
* be displayed or serialized by jackson. The only way to serialize an object annotated with this annotation is to use | ||
* {@link ca.uhn.fhir.util.JsonUtil}, as it has a registered filter against this annotation. | ||
*/ | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target(ElementType.FIELD) | ||
public @interface SensitiveNoDisplay {} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -135,6 +135,7 @@ public enum VersionEnum { | |
V6_11_0, | ||
|
||
V7_0_0, | ||
V7_0_1, | ||
|
||
V7_1_0, | ||
V7_2_0; | ||
|
54 changes: 54 additions & 0 deletions
54
hapi-fhir-base/src/test/java/ca/uhn/fhir/util/JsonUtilTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package ca.uhn.fhir.util; | ||
|
||
import ca.uhn.fhir.model.api.IModelJson; | ||
import ca.uhn.fhir.model.api.annotation.SensitiveNoDisplay; | ||
import com.fasterxml.jackson.annotation.JsonFilter; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.hamcrest.CoreMatchers.containsString; | ||
import static org.hamcrest.CoreMatchers.is; | ||
import static org.hamcrest.CoreMatchers.not; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
|
||
class JsonUtilTest { | ||
|
||
@JsonFilter(IModelJson.SENSITIVE_DATA_FILTER_NAME) | ||
class TestObject implements IModelJson { | ||
@JsonProperty("sensitiveField") | ||
@SensitiveNoDisplay | ||
private String mySensitiveField; | ||
|
||
@JsonProperty(value = "publicField") | ||
private String myPublicField; | ||
|
||
public String getPrivateField() { | ||
return mySensitiveField; | ||
} | ||
|
||
public void setSensitiveField(String thePrivateField) { | ||
this.mySensitiveField = thePrivateField; | ||
} | ||
|
||
public String getPublicField() { | ||
return myPublicField; | ||
} | ||
|
||
public void setPublicField(String thePublicField) { | ||
this.myPublicField = thePublicField; | ||
} | ||
} | ||
|
||
@Test | ||
public void testSensitiveNoDisplayAnnotationIsHiddenFromBasicSerialization() { | ||
TestObject object = new TestObject(); | ||
object.setPublicField("Public Value!"); | ||
object.setSensitiveField("Sensitive Value!"); | ||
|
||
String sensitiveExcluded = JsonUtil.serializeOrInvalidRequest(object); | ||
assertThat(sensitiveExcluded, is(not(containsString("Sensitive Value!")))); | ||
|
||
String sensitiveIncluded = JsonUtil.serializeWithSensitiveData(object); | ||
assertThat(sensitiveIncluded, is(containsString("Sensitive Value!"))); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
...ocs/src/main/resources/ca/uhn/hapi/fhir/changelog/7_0_0/5656-bulk-import-credentials.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
type: fix | ||
jira: SMILE-7216 | ||
title: "Previously, the Bulk Import (`$import`) job was ignoring the `httpBasicCredentials` section of the incoming parameters | ||
object, causing the job to fail with a 403 error. This has been corrected." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.