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

Minor changes #5

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/Anon.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import policy from './DefaultPolicy';
import sjcl from './sjcl.sha512'
import sjcl from './sjcl.sha512';
// Prefix from Medical Connections
const UIDPREFIX = "1.2.826.0.1.3680043.10.341.";
// We want to keep the hash algorithm the same to preserve references.
Expand All @@ -26,14 +26,21 @@ function randomUid() {
return UIDPREFIX + "777." + rando;
};

//CMHM new function to check that what is in fields is proper




// TODO: Test that there's no personal data stored outside the "Value" for a
// given tag. This should be the case, and we're making the assumption that the
// user is not maliciously trying to hide data.
export default function anonymize(dict) {
var newDict = {};
for(const key of Object.keys(dict)) {
// Use default action or action specified in policy
//CONSIDER MOVING NEXT LINE OUTSIDE THE LOOP! (CMHM)
Copy link
Contributor

Choose a reason for hiding this comment

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

We need to reset rule to the default policy for each loop iteration - otherwise, the policy rule for the previous field would be used if none were defined.

var rule = policy["default"];
//what happens if key is not in policy? ??? (CMHM)
if (key in policy) { rule = policy[key]; }
var action = rule["action"];
// For keep actions we can just pass the tag accross...
Expand Down