Skip to content

Commit 76d5732

Browse files
authored
MLE-28498 11.3.5 Test Fixes for Security Update (#1074)
* MLE-28498 Permission fixes This contains permission fixes for testing as a result of the 11.3.5 changes. * MLE-28498 transform test fixes Updated transforms tests to expect rest-transform-user as a result of 11.3.5 changes from ML-28684. * MLE-28498 dmsdk fixes Copilot fix for flakey dmsdk tests * MLE-28498 Skip optic-fromDocs tests for < 12.1 After confirming with the MarkLogic Server team, op:from-docs is only supported in MLS 12.1 since it is a new feature. I have added a skip for anything lower than MLS 12.1
1 parent 69fb7af commit 76d5732

11 files changed

Lines changed: 86 additions & 27 deletions

test-app/src/main/ml-config/security/roles/rest-evaluator.json

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"role-name": "rest-evaluator",
33
"description": "REST writer who can eval, invoke, or set a dynamic databases",
44
"role": [
5-
"rest-writer"
5+
"rest-writer",
6+
"sparql-update-user"
67
],
78
"privilege": [
89
{
@@ -49,6 +50,21 @@
4950
"privilege-name": "xdmp-get-session-field",
5051
"action": "http://marklogic.com/xdmp/privileges/xdmp-get-session-field",
5152
"kind": "execute"
53+
},
54+
{
55+
"privilege-name": "xdmp-login",
56+
"action": "http://marklogic.com/xdmp/privileges/xdmp-login",
57+
"kind": "execute"
58+
},
59+
{
60+
"privilege-name": "unprotected-collections",
61+
"action": "http://marklogic.com/xdmp/privileges/unprotected-collections",
62+
"kind": "execute"
63+
},
64+
{
65+
"privilege-name": "xdmp-xslt-invoke",
66+
"action": "http://marklogic.com/xdmp/privileges/xslt-invoke",
67+
"kind": "execute"
5268
}
5369
]
54-
}
70+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"role-name": "rest-login",
3+
"description": "Role granting xdmp:login privilege needed for REST transform invocations with different-transaction isolation",
4+
"privilege": [
5+
{
6+
"privilege-name": "xdmp-login",
7+
"action": "http://marklogic.com/xdmp/privileges/xdmp-login",
8+
"kind": "execute"
9+
}
10+
]
11+
}

test-app/src/main/ml-config/security/users/rest-admin.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
"description": "rest-admin user",
44
"password": "x",
55
"role": [
6-
"rest-admin"
6+
"rest-admin",
7+
"rest-evaluator",
8+
"rest-extension-user",
9+
"sparql-update-user"
710
]
8-
}
11+
}

test-app/src/main/ml-config/security/users/rest-reader.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
"description": "rest-reader user",
44
"password": "x",
55
"role": [
6-
"rest-reader"
6+
"rest-reader",
7+
"rest-extension-user",
8+
"rest-login"
79
]
8-
}
10+
}

test-app/src/main/ml-config/security/users/rest-temporal-writer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"description": "rest-writer user with temporal privileges",
44
"password": "x",
55
"role": [
6-
"rest-temporal-writer"
6+
"rest-temporal-writer",
7+
"rest-extension-user"
78
]
8-
}
9+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"user-name": "rest-transform-user",
3+
"description": "rest-transform-user user",
4+
"password": "x",
5+
"role": [
6+
"rest-transform-internal",
7+
"rest-reader",
8+
"rest-login"
9+
]
10+
}

test-app/src/main/ml-config/security/users/rest-writer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"role": [
66
"rest-writer",
77
"rest-evaluator",
8-
"temporal-admin"
8+
"temporal-admin",
9+
"rest-extension-user"
910
]
1011
}

test-basic/documents-transform.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,8 @@ describe('document transform', function(){
187187
documents.length.should.equal(1);
188188
documents[0].content.should.have.property('timestamp');
189189
documents[0].content.should.have.property('userName');
190-
documents[0].content.userName.should.eql('rest-writer');
190+
documents[0].content.userName.should.eql('rest-transform-user',
191+
'As of MarkLogic 11.3.5 and 12.0.2 JavaScript transforms execute as the dedicated rest-transform-user rather than the calling user\'s identity, preventing privilege escalation via malicious transforms');
191192
done();
192193
})
193194
.catch(done);
@@ -202,7 +203,8 @@ describe('document transform', function(){
202203
documents.length.should.equal(1);
203204
documents[0].content.should.have.property('timestamp');
204205
documents[0].content.should.have.property('userName');
205-
documents[0].content.userName.should.eql('rest-writer');
206+
documents[0].content.userName.should.eql('rest-transform-user',
207+
'As of MarkLogic 11.3.5 and 12.0.2 JavaScript transforms execute as the dedicated rest-transform-user rather than the calling user\'s identity, preventing privilege escalation via malicious transforms');
206208
done();
207209
})
208210
.catch(done);
@@ -221,7 +223,8 @@ describe('document transform', function(){
221223
documents.length.should.equal(1);
222224
documents[0].content.should.have.property('timestamp');
223225
documents[0].content.should.have.property('userName');
224-
documents[0].content.userName.should.eql('rest-writer');
226+
documents[0].content.userName.should.eql('rest-transform-user',
227+
'As of MarkLogic 11.3.5 and 12.0.2 JavaScript transforms execute as the dedicated rest-transform-user rather than the calling user\'s identity, preventing privilege escalation via malicious transforms');
225228
done();
226229
})
227230
.catch(done);

test-basic/optic-fromDocs.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ let uris = [];
2020
let serverConfiguration = {};
2121

2222
describe('optic-update fromDocs tests', function() {
23+
// NOTE: op.fromDocs() with op.columnBuilder() is only supported in MarkLogic 12.1.0 and later.
24+
// Tests in this suite are skipped automatically on earlier versions.
2325

2426
this.timeout(15000);
2527
before(function (done) {
@@ -34,6 +36,10 @@ describe('optic-update fromDocs tests', function() {
3436
describe('fromDocs', function () {
3537

3638
before(function (done) {
39+
if (serverConfiguration.serverVersion < 12.1) {
40+
this.skip();
41+
return;
42+
}
3743
// Insert test documents
3844
const testDocs = [
3945
{
@@ -73,7 +79,7 @@ describe('optic-update fromDocs tests', function() {
7379
}
7480
},
7581
{
76-
// we already have a geospatial element index for 'point' in wgs84
82+
// we already have a geospatial element index for 'point' in wgs84
7783
// in the test-app ml-gradle project. Use that. Use 'point' to indicate location.
7884
uri: '/test/fromDocs/location-portland.json',
7985
contentType: 'application/json',
@@ -127,14 +133,14 @@ describe('optic-update fromDocs tests', function() {
127133
}
128134
}
129135
];
130-
136+
131137
let readable = new Stream.Readable({objectMode: true});
132138
testDocs.forEach(doc => {
133139
readable.push(doc);
134140
uris.push(doc.uri);
135141
});
136142
readable.push(null);
137-
143+
138144
db.documents.writeAll(readable, {
139145
onCompletion: () => done()
140146
});
@@ -252,7 +258,7 @@ describe('optic-update fromDocs tests', function() {
252258

253259
const portlandPoint = op.cts.point(45.52, -122.68);
254260
const searchRadius = 650; // miles
255-
// geospatial element index is defined for 'point' in wgs84
261+
// geospatial element index is defined for 'point' in wgs84
256262
const plan = op.fromDocs(
257263
op.cts.collectionQuery('fromDocs'),
258264
'/location',
@@ -270,7 +276,7 @@ describe('optic-update fromDocs tests', function() {
270276
['coordinate-system=wgs84']
271277
)
272278
);
273-
279+
274280
execPlan(plan).then(function (response) {
275281
const output = getResults(response);
276282
output.length.should.be.equal(3);
@@ -340,4 +346,4 @@ describe('optic-update fromDocs tests', function() {
340346

341347

342348
});
343-
});
349+
});

test-complete/nodejs-dmsdk-readall-1.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
2-
* Copyright (c) 2015-2025 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
3-
*/
2+
* Copyright (c) 2015-2026 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
3+
*/
44
var fs = require('fs');
55
const path = require('path');
66

@@ -143,6 +143,7 @@ describe('readAll-tests-one', function () {
143143
function (err, arr) {
144144
if (err) {
145145
done(err);
146+
return;
146147
}
147148
arr.forEach(item => {
148149
setTimeout(() => {
@@ -158,8 +159,8 @@ describe('readAll-tests-one', function () {
158159
for (var c of resulContents) {
159160
expect(verifyCurrentContents(c)).to.be.true;
160161
}
162+
done();
161163
});
162-
done();
163164
});
164165

165166
it('readAll one document with batch options', function (done) {
@@ -173,15 +174,16 @@ describe('readAll-tests-one', function () {
173174
function (err, arr) {
174175
if (err) {
175176
done(err);
177+
return;
176178
}
177179
arr.forEach(item => {
178180
setTimeout(() => {
179181
var i = 0; i++;
180182
}, 3000);
181183
expect(item.uri).to.equal('dmsdk.txt');
182184
});
185+
done();
183186
});
184-
done();
185187
});
186188

187189
//Verify no errors when readAll has no Uris to read

0 commit comments

Comments
 (0)