-
-
Notifications
You must be signed in to change notification settings - Fork 182
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
281 additions
and
38 deletions.
There are no files selected for viewing
This file contains 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 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,132 @@ | ||
component extends = "org.lucee.cfml.test.LuceeTestCase" labels="xml" { | ||
function beforeAll(){ | ||
variables.uri = createURI("LDEV1676"); | ||
//systemOutput(" ", true); | ||
} | ||
|
||
function run( testresults , testbox ) { | ||
describe( "testcase for LDEV-1676", function () { | ||
it( title="Check xmlFeatures externalGeneralEntities=true, secure: false",body = function ( currentSpec ){ | ||
local.result = _InternalRequest( | ||
template : "#uri#/LDEV1676.cfm", | ||
forms : { scene: "externalGeneralEntities-True" } | ||
).filecontent; | ||
expect( trim( result ) ).toInclude("http://update.lucee.org/rest/update/provider/echoGet/cgi"); | ||
}); | ||
|
||
it( title="Check xmlFeatures externalGeneralEntities=false",body = function ( currentSpec ) { | ||
local.result = _InternalRequest( | ||
template : "#uri#/LDEV1676.cfm", | ||
forms : { scene: "externalGeneralEntities-False" } | ||
).filecontent; | ||
expect( trim( result ) ).toInclude("security restrictions set by XMLFeatures"); | ||
expect( trim( result ) ).toInclude("NullPointerException"); | ||
}); | ||
|
||
it( title="Check xmlFeatures disallowDoctypeDecl=true",body = function ( currentSpec ) { | ||
local.result = _InternalRequest( | ||
template : "#uri#/LDEV1676.cfm", | ||
forms : { scene: "disallowDoctypeDecl-True" } | ||
).filecontent; | ||
expect( trim( result ) ).toInclude("DOCTYPE"); | ||
}); | ||
}); | ||
|
||
describe( "check combined xmlFeatures directives", function () { | ||
|
||
it( title="Check xmlFeatures default, good xml",body = function ( currentSpec ) { | ||
local.result = _InternalRequest( | ||
template : "#uri#/LDEV1676.cfm", | ||
forms : { | ||
scene: "default", | ||
doctype: false, | ||
entity: false, | ||
} | ||
).filecontent; | ||
expect( trim( result ) ).toBe("lucee"); | ||
}); | ||
|
||
it( title="Check xmlFeatures default, bad xml",body = function ( currentSpec ) { | ||
local.result = _InternalRequest( | ||
template : "#uri#/LDEV1676.cfm", | ||
forms : { | ||
scene: "default", | ||
doctype: true, | ||
entity: true | ||
} | ||
).filecontent; | ||
expect( trim( result ) ).toInclude("DOCTYPE is disallowed when the feature"); | ||
}); | ||
|
||
it( title="Check xmlFeatures all secure, bad xml",body = function ( currentSpec ) { | ||
local.result = _InternalRequest( | ||
template : "#uri#/LDEV1676.cfm", | ||
forms : { | ||
scene: "all-secure", | ||
doctype: true, | ||
entity: true, | ||
} | ||
).filecontent; | ||
expect( trim( result ) ).toInclude("DOCTYPE is disallowed when the feature"); | ||
}); | ||
|
||
it( title="Check xmlFeatures all insecure, bad xml",body = function ( currentSpec ) { | ||
local.result = _InternalRequest( | ||
template : "#uri#/LDEV1676.cfm", | ||
forms : { | ||
scene: "all-insecure", | ||
doctype: true, | ||
entity: true | ||
} | ||
).filecontent; | ||
expect( trim( result ) ).toInclude("http://update.lucee.org/rest/update/provider/echoGet/cgi"); | ||
}); | ||
|
||
it( title="Check xmlFeatures all secure, good xml",body = function ( currentSpec ) { | ||
local.result = _InternalRequest( | ||
template : "#uri#/LDEV1676.cfm", | ||
forms : { | ||
scene: "all-secure", | ||
doctype: false, | ||
entity: false | ||
} | ||
).filecontent; | ||
expect( trim( result ) ).toBe("lucee"); | ||
}); | ||
|
||
}); | ||
|
||
describe( "check bad config handling", function () { | ||
|
||
it( title="Check xmlFeatures invalidConfig secure",body = function ( currentSpec ) { | ||
local.result = _InternalRequest( | ||
template : "#uri#/LDEV1676.cfm", | ||
forms : { scene: "invalidConfig-secure" } | ||
).filecontent; | ||
expect( trim( result ) ).toInclude( "casterException" ); | ||
}); | ||
|
||
it( title="Check xmlFeatures invalidConfig docType",body = function ( currentSpec ) { | ||
local.result = _InternalRequest( | ||
template : "#uri#/LDEV1676.cfm", | ||
forms : { scene: "invalidConfig-docType" } | ||
).filecontent; | ||
expect( trim( result ) ).toInclude( "casterException" ); | ||
}); | ||
|
||
it( title="Check xmlFeatures invalidConfig Entities",body = function ( currentSpec ) { | ||
local.result = _InternalRequest( | ||
template : "#uri#/LDEV1676.cfm", | ||
forms : { scene: "invalidConfig-Entities" } | ||
).filecontent; | ||
expect( trim( result ) ).toInclude( "casterException" ); | ||
}); | ||
|
||
}); | ||
} | ||
|
||
private string function createURI(string calledName){ | ||
var baseURI="/test/#listLast(getDirectoryFromPath(getCurrenttemplatepath()),"\/")#/"; | ||
return baseURI&""&calledName; | ||
} | ||
} |
This file contains 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,64 @@ | ||
component { | ||
this.name="LDEV1676"; | ||
param name="FORM.Scene"; | ||
param name="FORM.docType" default="true"; | ||
param name="FORM.entity" default="true"; | ||
|
||
switch (FORM.Scene){ | ||
case "externalGeneralEntities-True": | ||
this.xmlFeatures ={ | ||
"externalGeneralEntities": true, | ||
"disallowDoctypeDecl": false, | ||
"secure": false | ||
} | ||
break; | ||
case "externalGeneralEntities-False": | ||
this.xmlFeatures = { | ||
"externalGeneralEntities": false, | ||
"secure": true, | ||
"disallowDoctypeDecl": false | ||
}; | ||
break; | ||
case "disallowDoctypeDecl-True": | ||
this.xmlFeatures = { | ||
"externalGeneralEntities": false, | ||
"secure": true, | ||
"disallowDoctypeDecl": true | ||
}; | ||
break; | ||
case "invalidConfig-Secure": | ||
this.xmlFeatures = { | ||
"secure": "lucee" | ||
}; | ||
break; | ||
case "invalidConfig-Doctype": | ||
this.xmlFeatures = { | ||
"disallowDoctypeDecl": "lucee" | ||
}; | ||
break; | ||
case "invalidConfig-Entities": | ||
this.xmlFeatures = { | ||
"disallowDoctypeDecl": "lucee" | ||
}; | ||
break; | ||
case "all-secure": | ||
this.xmlFeatures = { | ||
"externalGeneralEntities": false, | ||
"secure": true, | ||
"disallowDoctypeDecl": true | ||
}; | ||
break; | ||
case "all-insecure": | ||
this.xmlFeatures = { | ||
"externalGeneralEntities": true, | ||
"secure": false, | ||
"disallowDoctypeDecl": false | ||
}; | ||
break; | ||
case "default": | ||
break; | ||
default: | ||
throw "unknown scene: #form.scene#"; | ||
break; | ||
} | ||
} |
This file contains 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,39 @@ | ||
<cfsavecontent variable="xml"><?xml version="1.0" encoding="ISO-8859-1"?> | ||
<cfif form.docType> | ||
<!DOCTYPE foo [ | ||
<!ELEMENT foo ANY > | ||
<cfif FORM.entity> | ||
<!ENTITY xxe SYSTEM "http://update.lucee.org/rest/update/provider/echoGet/cgi" > | ||
</cfif> | ||
]> | ||
</cfif> | ||
<cfif form.entity> | ||
<foo>&xxe;</foo> | ||
<cfelse> | ||
<foo>lucee</foo> | ||
</cfif> | ||
</cfsavecontent> | ||
<cfscript> | ||
/* | ||
settings = getApplicationSettings(); | ||
systemOutput( form.toJson(), true ); | ||
if (structKeyExists(settings, "xmlFeatures" ) ) { | ||
systemOutput( settings.xmlFeatures.toJson(), true ); | ||
} else { | ||
systemOutput("xmlFeatures not set", true); | ||
} | ||
systemOutput( "LDEV1676.cfc:" & CallStackGet( "array" )[ 2 ].linenumber, true ); | ||
systemOutput( xml, true ); | ||
*/ | ||
try { | ||
result = xmlSearch( xml, "/foo" )[1].xmltext; | ||
//systemOutput( result, true ); | ||
echo( result ); | ||
} catch (e) { | ||
//systemOutput(cfcatch.type & " " & cfcatch.message, true); | ||
echo( cfcatch.type & " " & cfcatch.message ); | ||
} | ||
</cfscript> |