Skip to content

Commit b080b61

Browse files
author
Bill Miller
committed
Swapping CORB for MLCP
Remved CORB task for validating redaction and replaced it with MCLP task
1 parent 92db544 commit b080b61

File tree

12 files changed

+68
-27
lines changed

12 files changed

+68
-27
lines changed
Lines changed: 60 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,87 @@
11
buildscript {
22
repositories {
33
jcenter()
4-
// Needed for corb dependency: XCC
4+
// Needed for mlcp dependency: XCC
55
maven { url "http://developer.marklogic.com/maven2/" }
66
}
77
dependencies {
8-
//Needed for CorbTask below
9-
classpath 'com.marklogic:marklogic-corb:2.3.2'
8+
classpath "com.marklogic:marklogic-contentpump:9.0.3"
9+
classpath "com.marklogic:ml-gradle:3.0.0"
1010
}
1111
}
1212

13-
plugins {
14-
id "com.marklogic.ml-gradle" version "3.0.0"
15-
}
13+
apply plugin: "com.marklogic.ml-gradle"
1614

1715
repositories {
1816
jcenter()
19-
20-
// Needed for corb dependency: XCC
17+
// Needed for mlcp dependency
2118
maven { url "http://developer.marklogic.com/maven2/" }
19+
maven { url "http://repository.cloudera.com/artifactory/cloudera-repos/" }
2220
}
2321

2422
configurations {
25-
// Needed to run corb task below.
26-
corb
23+
mlcp {
24+
resolutionStrategy {
25+
force "xml-apis:xml-apis:1.4.01"
26+
}
27+
}
2728
}
29+
30+
2831
dependencies {
29-
// required to run CoRB2
30-
corb 'com.marklogic:marklogic-corb:2.3.2'
31-
// optional
32+
mlcp "com.marklogic:mlcp:9.0.3"
33+
mlcp files("lib")
3234
}
35+
36+
/***************************************************************
37+
Optional tasks to test redaction of data
38+
***************************************************************/
39+
3340
/*
34-
* ml-gradle adds an instance of com.marklogic.appdeployer.AppConfig to the Gradle project under the key "mlAppConfig".
35-
* This instance can be modified to affect the behavior of ml-gradle.
36-
*/
37-
ext {
38-
mlAppConfig {
39-
// XCC URL for running corb task below
40-
contentXccUrl = "xcc://${mlUsername}:${mlPassword}@${mlHost}:${mlRestPort}"
41-
}
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"
4255
}
4356

57+
4458
/*
45-
* This optional task demonstrates validating redaction rules via a locally run CORB process.
46-
* To execute this task simply run it after you have successfully deployed the redaction rulesets (via mlAppDeploy or mlLoadSchemas).
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+
4783
*/
48-
task validateRedactionRulesetsAdhoc(type: com.marklogic.gradle.task.CorbTask) {
49-
xccConnectionUri = contentXccUrl
50-
urisModule = "src/main/ml-modules/ext/redaction-ruleset-validation/corb/redaction-rules-uris.xqy|ADHOC"
51-
processModule = "src/main/ml-modules/ext/redaction-ruleset-validation/corb/validate-redaction-rules.xqy|ADHOC"
5284

5385
}
5486

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.

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

Whitespace-only changes.

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

Whitespace-only changes.

0 commit comments

Comments
 (0)