Skip to content

Commit 965fa5b

Browse files
authored
Merge pull request #250 from millerbill3/feature/#168-redaction-ruleset
Feature/#168 redaction ruleset
2 parents 0a446e1 + 8bc0ab6 commit 965fa5b

File tree

20 files changed

+157
-0
lines changed

20 files changed

+157
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/bin
2+
.classpath
3+
.project
4+
/build
5+
.gradle
6+
.settings
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
This project shows an example of how MarkLogic 9 Redaction Rulesets can be loaded into a schemas
2+
database from src/main/ml-schemas (the default path - this can be overridden via
3+
mlSchemasPath).
4+
5+
Note that in order for this to work, the content-database.json file must specify the schema
6+
database that it's associated with. And in most cases, you'll want your own schemas database - not the default Schemas one - so schemas-database.json can be used to create own with a name based on mlAppName.
7+
8+
Within each folder containing one or more Redaction Rulesets, you must provide a **collections.properties** and (optionally) a **permissions.properties** file.
9+
These files contain the definitions for the applicable collections to be applied to the rulesets as well as the document permissions (if included).
10+
11+
***Note***: Rulesets must have a .json or .xml file extension.
12+
13+
See [Specifying collections and permissions](https://github.com/marklogic-community/ml-javaclient-util/wiki/Loading-files#specifying-collections-and-permissions) for information on how to apply the collections and permission when the rulesets are loaded
14+
15+
See [Redacting Document Content](http://docs.marklogic.com/guide/app-dev/redaction) for more information on redacting content
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
buildscript {
2+
repositories {
3+
jcenter()
4+
// Needed for mlcp dependency: XCC
5+
maven { url "http://developer.marklogic.com/maven2/" }
6+
}
7+
dependencies {
8+
classpath "com.marklogic:marklogic-contentpump:9.0.3"
9+
classpath "com.marklogic:ml-gradle:3.0.0"
10+
}
11+
}
12+
13+
apply plugin: "com.marklogic.ml-gradle"
14+
15+
repositories {
16+
jcenter()
17+
// Needed for mlcp dependency
18+
maven { url "http://developer.marklogic.com/maven2/" }
19+
maven { url "http://repository.cloudera.com/artifactory/cloudera-repos/" }
20+
}
21+
22+
configurations {
23+
mlcp {
24+
resolutionStrategy {
25+
force "xml-apis:xml-apis:1.4.01"
26+
}
27+
}
28+
}
29+
30+
31+
dependencies {
32+
mlcp "com.marklogic:mlcp:9.0.3"
33+
mlcp files("lib")
34+
}
35+
36+
/***************************************************************
37+
Optional tasks to test redaction of data
38+
***************************************************************/
39+
40+
/*
41+
* The import task below is an example of using the built-in MLCP Task in ml-gradle and will import sample JSON
42+
* documents to the specified content database while applying the applicable collections to the content so that
43+
* the redaction rules can be applied
44+
* */
45+
task importSampleRedactionData(type: com.marklogic.gradle.task.MlcpTask) {
46+
description = "Example of using mlcp and MlcpTask to import documents to test redaction rules"
47+
classpath = configurations.mlcp
48+
command = "IMPORT"
49+
database = mlAppConfig.contentDatabaseName
50+
input_file_path = "data/import"
51+
output_collections = "security-rules,pii-rules,email-rules"
52+
output_permissions = "rest-reader,read,rest-writer,update"
53+
output_uri_replace = ".*import,'/import'"
54+
logOutputUri = "/redaction.txt"
55+
}
56+
57+
58+
/*
59+
* The export task below shows an example of using JavaExec inside Gradle to invoke MLCP to export the documents.
60+
* This task, while a useful example, must be invoked this way because the built-in MLCP task does not yet recognize
61+
* the "redaction" option being passed. This will be addressed in a future release.
62+
* Exported documents will be within this project folder under /data/export
63+
* */
64+
task exportSampleRedactionData(type: JavaExec) {
65+
classpath = configurations.mlcp
66+
main = 'com.marklogic.contentpump.ContentPump'
67+
68+
args = [
69+
"EXPORT",
70+
"-host", "${mlHost}",
71+
"-port", "8130",
72+
"-username", "${mlUsername}",
73+
"-password", "${mlPassword}",
74+
"-database", mlAppConfig.contentDatabaseName,
75+
"-output_file_path", "data/export",
76+
"-collection_filter", "security-rules",
77+
"-redaction", "security-rules"]
78+
/*
79+
* Applying "security-rules" as the redaction collection will redact both email and SSN fields in the documents
80+
* You may also redact just the email or ths SSN fields individually by applying only those specific collections
81+
* i.e. "pii-rules" OR "email-rules"
82+
83+
*/
84+
85+
}
86+
87+

examples/redaction-ruleset-project/data/import/sample1.json

Whitespace-only changes.

examples/redaction-ruleset-project/data/import/sample10.json

Whitespace-only changes.

examples/redaction-ruleset-project/data/import/sample2.json

Whitespace-only changes.

examples/redaction-ruleset-project/data/import/sample3.json

Whitespace-only changes.

examples/redaction-ruleset-project/data/import/sample4.json

Whitespace-only changes.

examples/redaction-ruleset-project/data/import/sample5.json

Whitespace-only changes.

examples/redaction-ruleset-project/data/import/sample6.json

Whitespace-only changes.

0 commit comments

Comments
 (0)