To fix the problem, we need to configure the SchemaFactory to disable DTDs and external entities. This can be done by setting specific features on the SchemaFactory instance. The best way to fix this without changing existing functionality is to add these configurations in the constructor of the SchemaValidator class.
Set the feature http://apache.org/xml/features/disallow-doctype-decl to true to disallow DTDs.
Set the feature http://xml.org/sax/features/external-general-entities to false to disallow external general entities.
Set the feature http://xml.org/sax/features/external-parameter-entities to false to disallow external parameter entities.
Suggested fixes powered by Copilot Autofix. Review carefully before merging.
Fixes https://github.com/NASA-PDS/validate/security/code-scanning/468
To fix the problem, we need to configure the
SchemaFactory
to disable DTDs and external entities. This can be done by setting specific features on theSchemaFactory
instance. The best way to fix this without changing existing functionality is to add these configurations in the constructor of theSchemaValidator
class.http://apache.org/xml/features/disallow-doctype-decl
totrue
to disallow DTDs.http://xml.org/sax/features/external-general-entities
tofalse
to disallow external general entities.http://xml.org/sax/features/external-parameter-entities
tofalse
to disallow external parameter entities.Suggested fixes powered by Copilot Autofix. Review carefully before merging.