code
stringlengths 14
2.05k
| label
int64 0
1
| programming_language
stringclasses 7
values | cwe_id
stringlengths 6
14
| cwe_name
stringlengths 5
98
⌀ | description
stringlengths 36
379
⌀ | url
stringlengths 36
48
⌀ | label_name
stringclasses 2
values |
---|---|---|---|---|---|---|---|
public void t1canSetConfigParm() throws Exception {
IProject project = checkProject();
assertNotNull(project);
IPath path = project.getLocation();
path = path.append(".autotools");
File f = new File(path.toOSString());
assertTrue(f.exists());
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document d = db.parse(f);
Element e = d.getDocumentElement();
// Get the stored configuration data
NodeList cfgs = e.getElementsByTagName("configuration"); //$NON-NLS-1$
assertTrue(cfgs.getLength() > 0);
Node n = cfgs.item(0);
NodeList l = n.getChildNodes();
// Verify user field in .autotools file is set to --enable-jeff
boolean foundUser = false;
for (int y = 0; y < l.getLength(); ++y) {
Node child = l.item(y);
if (child.getNodeName().equals("option")) { //$NON-NLS-1$
NamedNodeMap optionAttrs = child.getAttributes();
Node idNode = optionAttrs.getNamedItem("id"); //$NON-NLS-1$
Node valueNode = optionAttrs.getNamedItem("value"); //$NON-NLS-1$
assertNotNull(idNode);
assertNotNull(valueNode);
String id = idNode.getNodeValue();
String value = valueNode.getNodeValue();
if (id.equals("user")) {
foundUser = true;
assertEquals(value, "--enable-jeff");
}
}
}
assertTrue(foundUser);
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
protected static Document getAMDoc(String amDocVer) {
Document amDocument = null;
if (amHoverDocs == null) {
amHoverDocs = new HashMap<>();
}
amDocument = amHoverDocs.get(amDocVer);
if (amDocument == null) {
Document doc = null;
try {
// see comment in initialize()
try {
InputStream docStream = null;
try {
URI uri = new URI(getLocalAutomakeMacrosDocName(amDocVer));
IPath p = URIUtil.toPath(uri);
// Try to open the file as local to this plug-in.
docStream = FileLocator.openStream(AutotoolsUIPlugin.getDefault().getBundle(), p, false);
} catch (IOException e) {
// Local open failed. Try normal external location.
URI acDoc = new URI(getAutomakeMacrosDocName(amDocVer));
IPath p = URIUtil.toPath(acDoc);
if (p == null) {
URL url = acDoc.toURL();
docStream = url.openStream();
} else {
docStream = new FileInputStream(p.toFile());
}
}
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setValidating(false);
try {
DocumentBuilder builder = factory.newDocumentBuilder();
doc = builder.parse(docStream);
} catch (SAXException | ParserConfigurationException | IOException ex) {
doc = null;
} finally {
if (docStream != null)
docStream.close();
}
} catch (FileNotFoundException | MalformedURLException | URISyntaxException e) {
AutotoolsPlugin.log(e);
}
amDocument = doc;
} catch (IOException ioe) {
}
}
amHoverDocs.put(amDocVer, amDocument);
return amDocument;
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
protected static Document getACDoc(String acDocVer) {
Document acDocument = null;
if (acHoverDocs == null) {
acHoverDocs = new HashMap<>();
}
acDocument = acHoverDocs.get(acDocVer);
if (acDocument == null) {
Document doc = null;
try {
// see comment in initialize()
try {
InputStream docStream = null;
try {
URI uri = new URI(getLocalAutoconfMacrosDocName(acDocVer));
IPath p = URIUtil.toPath(uri);
// Try to open the file as local to this plug-in.
docStream = FileLocator.openStream(AutotoolsUIPlugin.getDefault().getBundle(), p, false);
} catch (IOException e) {
// Local open failed. Try normal external location.
URI acDoc = new URI(getAutoconfMacrosDocName(acDocVer));
IPath p = URIUtil.toPath(acDoc);
if (p == null) {
URL url = acDoc.toURL();
docStream = url.openStream();
} else {
docStream = new FileInputStream(p.toFile());
}
}
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setValidating(false);
try {
DocumentBuilder builder = factory.newDocumentBuilder();
doc = builder.parse(docStream);
} catch (SAXException | ParserConfigurationException | IOException saxEx) {
doc = null;
} finally {
if (docStream != null)
docStream.close();
}
} catch (FileNotFoundException | MalformedURLException | URISyntaxException e) {
AutotoolsPlugin.log(e);
}
acDocument = doc;
} catch (IOException ioe) {
}
}
acHoverDocs.put(acDocVer, acDocument);
return acDocument;
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
protected ICStorageElement translateInputStreamToDocument(InputStream input) {
try {
Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(input);
return XmlStorageUtil.createCStorageTree(document);
} catch (Exception e) {
MakeCorePlugin.log(e);
}
return null;
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
public void saveDiscoveredScannerInfoToState(IProject project, InfoContext context,
IDiscoveredScannerInfoSerializable serializable) throws CoreException {
Document document = getDocument(project);
// Create document
try {
saveDiscoveredScannerInfo(context, serializable, document);
// Transform the document to something we can save in a file
ByteArrayOutputStream stream = new ByteArrayOutputStream();
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); //$NON-NLS-1$
transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
DOMSource source = new DOMSource(document);
StreamResult result = new StreamResult(stream);
transformer.transform(source, result);
// Save the document
try {
IPath path = getDiscoveredScannerConfigStore(project);
FileOutputStream file = new FileOutputStream(path.toFile());
file.write(stream.toByteArray());
file.close();
} catch (IOException e) {
throw new CoreException(new Status(IStatus.ERROR, MakeCorePlugin.getUniqueIdentifier(), -1,
MakeMessages.getString("DiscoveredPathManager.File_Error_Message"), e)); //$NON-NLS-1$
}
// Close the streams
stream.close();
} catch (TransformerException e) {
MakeCorePlugin.log(e);
throw new CoreException(new Status(IStatus.ERROR, MakeCorePlugin.getUniqueIdentifier(), -1,
MakeMessages.getString("DiscoveredPathManager.File_Error_Message"), e)); //$NON-NLS-1$
} catch (IOException e) {
MakeCorePlugin.log(e);
throw new CoreException(new Status(IStatus.ERROR, MakeCorePlugin.getUniqueIdentifier(), -1,
MakeMessages.getString("DiscoveredPathManager.File_Error_Message"), e)); //$NON-NLS-1$
}
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
private Document getDocument(IProject project) throws CoreException {
// Get the document
Reference<Document> ref = fDocumentCache.get(project);
Document document = ref != null ? ref.get() : null;
if (document == null) {
try {
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
IPath path = getDiscoveredScannerConfigStore(project);
if (path.toFile().exists()) {
// read form file
FileInputStream file = new FileInputStream(path.toFile());
document = builder.parse(file);
Node rootElem = document.getFirstChild();
if (rootElem.getNodeType() != Node.PROCESSING_INSTRUCTION_NODE) {
// no version info; upgrade
upgradeDocument(document, project);
}
} else {
// create new document
document = builder.newDocument();
ProcessingInstruction pi = document.createProcessingInstruction(SCD_STORE_VERSION, "version=\"2\""); //$NON-NLS-1$
document.appendChild(pi);
Element rootElement = document.createElement(SI_ELEM);
rootElement.setAttribute(ID_ATTR, CDESCRIPTOR_ID);
document.appendChild(rootElement);
}
fDocumentCache.put(project, new SoftReference<>(document));
} catch (IOException e) {
MakeCorePlugin.log(e);
throw new CoreException(new Status(IStatus.ERROR, MakeCorePlugin.getUniqueIdentifier(), -1,
MakeMessages.getString("DiscoveredPathManager.File_Error_Message"), e)); //$NON-NLS-1$
} catch (ParserConfigurationException e) {
MakeCorePlugin.log(e);
throw new CoreException(new Status(IStatus.ERROR, MakeCorePlugin.getUniqueIdentifier(), -1,
MakeMessages.getString("DiscoveredPathManager.File_Error_Message"), e)); //$NON-NLS-1$
} catch (SAXException e) {
MakeCorePlugin.log(e);
throw new CoreException(new Status(IStatus.ERROR, MakeCorePlugin.getUniqueIdentifier(), -1,
MakeMessages.getString("DiscoveredPathManager.File_Error_Message"), e)); //$NON-NLS-1$
}
}
return document;
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
public static boolean manages(IResource resource) {
ICProjectDescription des = CoreModel.getDefault().getProjectDescription(resource.getProject(), false);
if (des == null) {
return false;
}
ICConfigurationDescription cfgDes = des.getActiveConfiguration();
IConfiguration cfg = ManagedBuildManager.getConfigurationForDescription(cfgDes);
if (cfg != null)
return true;
return false;
// // The managed build manager manages build information for the
// // resource IFF it it is a project and has a build file with the proper
// // root element
// IProject project = null;
// if (resource instanceof IProject){
// project = (IProject)resource;
// } else if (resource instanceof IFile) {
// project = ((IFile)resource).getProject();
// } else {
// return false;
// }
// IFile file = project.getFile(SETTINGS_FILE_NAME);
// if (file.exists()) {
// try {
// InputStream stream = file.getContents();
// DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
// Document document = parser.parse(stream);
// NodeList nodes = document.getElementsByTagName(ROOT_NODE_NAME);
// return (nodes.getLength() > 0);
// } catch (Exception e) {
// return false;
// }
// }
// return false;
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
public static void main(String[] args) {
Test test = new Test();
try {
XMLDumper dumper = new XMLDumper(test);
Document document = dumper.getDocument();
StringWriter writer = new StringWriter();
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.transform(new DOMSource(document), new StreamResult(writer));
System.out.println("STRXML = " + writer.toString()); //Spit out DOM as a String //$NON-NLS-1$
} catch (TransformerException e) {
e.printStackTrace();
} catch (ParserConfigurationException e) {
e.printStackTrace();
}
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
public XMLDumper(Object obj) throws ParserConfigurationException {
document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
document.appendChild(createObject(obj));
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
private Transformer createSerializer() throws CoreException {
try {
return TransformerFactory.newInstance().newTransformer();
} catch (TransformerConfigurationException e) {
throw new CoreException(Util.createStatus(e));
} catch (TransformerFactoryConfigurationError e) {
throw new CoreException(Util.createStatus(e));
}
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
public void storeMappings(WorkspaceLanguageConfiguration config) throws CoreException {
try {
// Encode mappings as XML and serialize as a String.
Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
Element rootElement = doc.createElement(WORKSPACE_MAPPINGS);
doc.appendChild(rootElement);
addContentTypeMappings(config.getWorkspaceMappings(), rootElement);
Transformer serializer = createSerializer();
DOMSource source = new DOMSource(doc);
StringWriter buffer = new StringWriter();
StreamResult result = new StreamResult(buffer);
serializer.transform(source, result);
String encodedMappings = buffer.getBuffer().toString();
IEclipsePreferences node = InstanceScope.INSTANCE.getNode(CCorePlugin.PLUGIN_ID);
node.put(CCorePreferenceConstants.WORKSPACE_LANGUAGE_MAPPINGS, encodedMappings);
node.flush();
} catch (ParserConfigurationException e) {
throw new CoreException(Util.createStatus(e));
} catch (TransformerException e) {
throw new CoreException(Util.createStatus(e));
} catch (BackingStoreException e) {
throw new CoreException(Util.createStatus(e));
}
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
public WorkspaceLanguageConfiguration decodeWorkspaceMappings() throws CoreException {
IEclipsePreferences node = InstanceScope.INSTANCE.getNode(CCorePlugin.PLUGIN_ID);
IEclipsePreferences defaultNode = DefaultScope.INSTANCE.getNode(CCorePlugin.PLUGIN_ID);
String encodedMappings = node.get(CCorePreferenceConstants.WORKSPACE_LANGUAGE_MAPPINGS, null);
if (encodedMappings == null) {
encodedMappings = defaultNode.get(CCorePreferenceConstants.WORKSPACE_LANGUAGE_MAPPINGS, null);
}
WorkspaceLanguageConfiguration config = new WorkspaceLanguageConfiguration();
if (encodedMappings == null || encodedMappings.length() == 0) {
return config;
}
// The mappings are encoded as XML in a String so we need to parse it.
InputSource input = new InputSource(new StringReader(encodedMappings));
try {
Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(input);
config.setWorkspaceMappings(decodeContentTypeMappings(document.getDocumentElement()));
return config;
} catch (SAXException e) {
throw new CoreException(Util.createStatus(e));
} catch (IOException e) {
throw new CoreException(Util.createStatus(e));
} catch (ParserConfigurationException e) {
throw new CoreException(Util.createStatus(e));
}
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
private synchronized void initExtensionPoints() {
if (storageTypeMap != null)
return;
Map<String, List<CProjectDescriptionStorageTypeProxy>> m = new HashMap<>();
IExtensionPoint extpoint = Platform.getExtensionRegistry().getExtensionPoint(CCorePlugin.PLUGIN_ID,
CPROJ_DESC_STORAGE_EXT_ID);
for (IExtension extension : extpoint.getExtensions()) {
for (IConfigurationElement configEl : extension.getConfigurationElements()) {
if (configEl.getName().equalsIgnoreCase(CPROJ_STORAGE_TYPE)) {
CProjectDescriptionStorageTypeProxy type = initStorageType(configEl);
if (type != null) {
if (!m.containsKey(type.id))
m.put(type.id, new LinkedList<CProjectDescriptionStorageTypeProxy>());
m.get(type.id).add(type);
}
}
}
}
storageTypeMap = m;
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
public Element createXmlElementCopy(InternalXmlStorageElement el) throws CoreException {
try {
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document doc = builder.newDocument();
Element newXmlEl = null;
synchronized (doc) {
synchronized (el.fLock) {
if (el.fElement.getParentNode().getNodeType() == Node.DOCUMENT_NODE) {
Document baseDoc = el.fElement.getOwnerDocument();
NodeList list = baseDoc.getChildNodes();
for (int i = 0; i < list.getLength(); i++) {
Node node = list.item(i);
node = importAddNode(doc, node);
if (node.getNodeType() == Node.ELEMENT_NODE && newXmlEl == null) {
newXmlEl = (Element) node;
}
}
} else {
newXmlEl = (Element) importAddNode(doc, el.fElement);
}
return newXmlEl;
}
}
} catch (ParserConfigurationException e) {
throw ExceptionFactory.createCoreException(e);
} catch (FactoryConfigurationError e) {
throw ExceptionFactory.createCoreException(e);
}
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
private ByteArrayOutputStream write(ICStorageElement element) throws CoreException {
Document doc = ((InternalXmlStorageElement) element).fElement.getOwnerDocument();
XmlUtil.prettyFormat(doc);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
try {
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); //$NON-NLS-1$
// Indentation is done with XmlUtil.prettyFormat(doc)
transformer.setOutputProperty(OutputKeys.INDENT, "no"); //$NON-NLS-1$
DOMSource source = new DOMSource(doc);
StreamResult result = new StreamResult(stream);
transformer.transform(source, result);
return stream;
} catch (TransformerConfigurationException e) {
throw ExceptionFactory.createCoreException(e);
} catch (TransformerException e) {
throw ExceptionFactory.createCoreException(e);
}
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
private ICStorageElement readOldCDTProjectFile(IProject project) throws CoreException {
ICStorageElement storage = null;
try {
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document doc = null;
InputStream stream = getSharedProperty(project, OLD_CDTPROJECT_FILE_NAME);
if (stream != null) {
doc = builder.parse(stream);
NodeList nodeList = doc.getElementsByTagName(OLD_PROJECT_DESCRIPTION);
if (nodeList != null && nodeList.getLength() > 0) {
Node node = nodeList.item(0);
storage = new InternalXmlStorageElement((Element) node, false);
}
}
} catch (ParserConfigurationException e) {
throw ExceptionFactory.createCoreException(e);
} catch (SAXException e) {
throw ExceptionFactory.createCoreException(e);
} catch (IOException e) {
throw ExceptionFactory.createCoreException(e);
}
return storage;
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
protected Element createXmlElementCopy() throws CoreException {
try {
synchronized (fLock) {
Element newXmlEl = null;
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document doc = builder.newDocument();
synchronized (doc) {
if (fElement.getParentNode().getNodeType() == Node.DOCUMENT_NODE) {
Document baseDoc = fElement.getOwnerDocument();
NodeList list = baseDoc.getChildNodes();
for (int i = 0; i < list.getLength(); i++) {
Node node = list.item(i);
node = importAddNode(doc, node);
if (node.getNodeType() == Node.ELEMENT_NODE && newXmlEl == null) {
newXmlEl = (Element) node;
}
}
} else {
newXmlEl = (Element) importAddNode(doc, fElement);
}
}
return newXmlEl;
}
} catch (ParserConfigurationException e) {
throw ExceptionFactory.createCoreException(e);
} catch (FactoryConfigurationError e) {
throw ExceptionFactory.createCoreException(e);
}
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
public String toString() {
StringBuilder builder = new StringBuilder();
synchronized (fLock) {
try {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
Transformer transformer = TransformerFactory.newInstance().newTransformer();
// Indentation is done with XmlUtil.prettyFormat(doc).
// For debugging, the prettyFormat may not have been run yet,
// so turning this to "yes" may be helpful on occasion.
transformer.setOutputProperty(OutputKeys.INDENT, "no"); //$NON-NLS-1$
DOMSource source = new DOMSource(fElement);
StreamResult result = new StreamResult(stream);
transformer.transform(source, result);
builder.append(stream.toString());
} catch (Exception e) {
return fElement.toString();
}
}
return builder.toString();
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
private UserDefinedVariableSupplier() {
fListeners = Collections.synchronizedSet(new HashSet<ICdtVariableChangeListener>());
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
private StorableCdtVariables loadMacrosFromStream(InputStream stream, boolean readOnly) {
try {
DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
InputSource inputSource = new InputSource(stream);
Document document = parser.parse(inputSource);
Element rootElement = document.getDocumentElement();
if (!StorableCdtVariables.MACROS_ELEMENT_NAME.equals(rootElement.getNodeName()))
return null;
return new StorableCdtVariables(new XmlStorageElement(rootElement), readOnly);
} catch (ParserConfigurationException e) {
} catch (SAXException e) {
} catch (IOException e) {
}
return null;
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
private ByteArrayOutputStream storeMacrosToStream(StorableCdtVariables macros) throws CoreException {
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.newDocument();
Element rootElement = document.createElement(StorableCdtVariables.MACROS_ELEMENT_NAME);
document.appendChild(rootElement);
ICStorageElement storageElement = new XmlStorageElement(rootElement);
macros.serialize(storageElement);
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); //$NON-NLS-1$
transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
DOMSource source = new DOMSource(document);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
StreamResult result = new StreamResult(stream);
transformer.transform(source, result);
return stream;
} catch (ParserConfigurationException e) {
throw ExceptionFactory.createCoreException(e.getMessage(), e);
} catch (TransformerConfigurationException e) {
throw ExceptionFactory.createCoreException(e.getMessage(), e);
} catch (TransformerException e) {
throw ExceptionFactory.createCoreException(e.getMessage(), e);
}
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
public void updateToBackEndStorage(String updateName, String updateValue) {
try {
document = DocumentBuilderFactory.newInstance().newDocumentBuilder()
.parse(parsedXML.toURI().toURL().openStream());
} catch (Exception exp) {
TemplateEngineUtil.log(exp);
}
persistDataMap.putAll(sharedDefaultsMap);
List<Element> sharedElementList = TemplateEngine.getChildrenOfElement(document.getDocumentElement());
int elementListSize = sharedElementList.size();
for (int i = 0; i < elementListSize; i++) {
Element xmlElement = sharedElementList.get(i);
String name = xmlElement.getAttribute(TemplateEngineHelper.ID);
if (updateName.equals(name)) {
persistDataMap.put(updateName, updateValue);
}
}
updateShareDefaultsMap(persistDataMap);
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
private void initSharedDefaults() {
String key = null;
String value = null;
try {
long length = parsedXML.length();
// Adds defaultXML format if the file length is zero
if (length == 0) {
parsedXML = createDefaultXMLFormat(parsedXML);
}
document = DocumentBuilderFactory.newInstance().newDocumentBuilder()
.parse(parsedXML.toURI().toURL().openStream());
} catch (Exception exp) {
TemplateEngineUtil.log(exp);
}
List<Element> sharedElementList = TemplateEngine.getChildrenOfElement(document.getDocumentElement());
int listSize = sharedElementList.size();
for (int i = 0; i < listSize; i++) {
Element xmlElement = sharedElementList.get(i);
key = xmlElement.getAttribute(TemplateEngineHelper.ID);
value = xmlElement.getAttribute(TemplateEngineHelper.VALUE);
if (key != null && !key.trim().isEmpty()) {
sharedDefaultsMap.put(key, value);
}
}
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
public void deleteBackEndStorage(String[] deleteName) {
try {
document = DocumentBuilderFactory.newInstance().newDocumentBuilder()
.parse(parsedXML.toURI().toURL().openStream());
} catch (Exception exp) {
TemplateEngineUtil.log(exp);
}
List<Element> sharedElementList = TemplateEngine.getChildrenOfElement(document.getDocumentElement());
int elementListSize = sharedElementList.size();
for (int i = 0; i < elementListSize; i++) {
Element xmlElement = sharedElementList.get(i);
String name = xmlElement.getAttribute(TemplateEngineHelper.ID);
for (int k = 0; k < deleteName.length; k++) {
if (deleteName[k].equals(name)) {
xmlElement.removeAttribute(name);
sharedDefaultsMap.remove(name);
}
}
}
updateShareDefaultsMap(sharedDefaultsMap);
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
private File createDefaultXMLFormat(File xmlFile) {
Document d;
try {
d = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
} catch (ParserConfigurationException e) {
TemplateEngineUtil.log(e);
return xmlFile;
}
Node rootElement = d.appendChild(d.createElement("SharedRoot")); //$NON-NLS-1$
Element element = (Element) rootElement.appendChild(d.createElement("SharedProperty")); //$NON-NLS-1$
element.setAttribute(TemplateEngineHelper.ID, ""); //$NON-NLS-1$
element.setAttribute(TemplateEngineHelper.VALUE, ""); //$NON-NLS-1$
DOMSource domSource = new DOMSource(d);
TransformerFactory transFactory = TransformerFactory.newInstance();
try {
FileOutputStream fos = null;
try {
fos = new FileOutputStream(xmlFile);
Result fileResult = new StreamResult(fos);
transFactory.newTransformer().transform(domSource, fileResult);
} finally {
if (fos != null) {
fos.close();
}
}
} catch (IOException ioe) {
TemplateEngineUtil.log(ioe);
} catch (TransformerConfigurationException tce) {
TemplateEngineUtil.log(tce);
} catch (TransformerException te) {
TemplateEngineUtil.log(te);
}
return xmlFile;
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
private void generateSharedXML(File xmlFile) {
Document d;
try {
d = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
} catch (ParserConfigurationException e) {
TemplateEngineUtil.log(e);
return;
}
Node rootElement = d.appendChild(d.createElement("SharedRoot")); //$NON-NLS-1$
for (String key : sharedDefaultsMap.keySet()) {
Element element = (Element) rootElement.appendChild(d.createElement("SharedProperty")); //$NON-NLS-1$
element.setAttribute(TemplateEngineHelper.ID, key);
element.setAttribute(TemplateEngineHelper.VALUE, sharedDefaultsMap.get(key));
}
DOMSource domSource = new DOMSource(d);
TransformerFactory transFactory = TransformerFactory.newInstance();
Result fileResult = new StreamResult(xmlFile);
try {
transFactory.newTransformer().transform(domSource, fileResult);
} catch (Throwable t) {
TemplateEngineUtil.log(t);
}
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
public TemplateDescriptor(URL descriptorURL, String pluginId) throws TemplateInitializationException {
String msg = NLS.bind(Messages.TemplateCore_init_failed, descriptorURL.toString());
try {
this.document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(descriptorURL.openStream());
} catch (ParserConfigurationException pce) {
throw new TemplateInitializationException(msg, pce);
} catch (IOException ioe) {
throw new TemplateInitializationException(msg, ioe);
} catch (SAXException se) {
throw new TemplateInitializationException(msg, se);
}
this.rootElement = document.getDocumentElement();
this.persistVector = new ArrayList<>();
this.pluginId = pluginId;
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
private static Document loadXml(InputStream xmlStream) throws CoreException {
try {
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
return builder.parse(xmlStream);
} catch (Exception e) {
throw new CoreException(CCorePlugin.createStatus(Messages.XmlUtil_InternalErrorLoading, e));
}
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
public static Document newDocument() throws ParserConfigurationException {
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
return builder.newDocument();
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
private static byte[] toByteArray(Document doc) throws CoreException {
try {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
transformer.setOutputProperty(OutputKeys.ENCODING, ENCODING_UTF_8);
// Indentation is done with XmlUtil.prettyFormat(doc).
transformer.setOutputProperty(OutputKeys.INDENT, "no"); //$NON-NLS-1$
DOMSource source = new DOMSource(doc);
StreamResult result = new StreamResult(stream);
transformer.transform(source, result);
return stream.toByteArray();
} catch (Exception e) {
throw new CoreException(CCorePlugin.createStatus(Messages.XmlUtil_InternalErrorSerializing, e));
}
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
static ICStorageElement environmentStorageFromString(String env) {
if (env == null)
return null;
try {
DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
InputSource inputSource = new InputSource(new ByteArrayInputStream(env.getBytes()));
Document document = parser.parse(inputSource);
Element el = document.getDocumentElement();
XmlStorageElement rootElement = new XmlStorageElement(el);
if (!StorableEnvironment.ENVIRONMENT_ELEMENT_NAME.equals(rootElement.getName()))
return null;
return rootElement;
} catch (ParserConfigurationException e) {
CCorePlugin.log(e);
} catch (SAXException e) {
CCorePlugin.log(e);
} catch (IOException e) {
CCorePlugin.log(e);
}
return null;
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
private ByteArrayOutputStream storeEnvironmentToStream(StorableEnvironment env) throws CoreException {
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.newDocument();
Element el = document.createElement(StorableEnvironment.ENVIRONMENT_ELEMENT_NAME);
document.appendChild(el);
XmlStorageElement rootElement = new XmlStorageElement(el);
env.serialize(rootElement);
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); //$NON-NLS-1$
transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
DOMSource source = new DOMSource(document);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
StreamResult result = new StreamResult(stream);
transformer.transform(source, result);
return stream;
} catch (ParserConfigurationException e) {
throw new CoreException(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, -1, e.getMessage(), e));
} catch (TransformerConfigurationException e) {
throw new CoreException(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, -1, e.getMessage(), e));
} catch (TransformerException e) {
throw new CoreException(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, -1, e.getMessage(), e));
}
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
private String getValueFromBackEndStorate(String key) throws Exception {
File parsedXML = TemplateEngineHelper.getSharedDefaultLocation("shareddefaults.xml");
Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder()
.parse(parsedXML.toURI().toURL().openStream());
List<Element> sharedElementList = TemplateEngine.getChildrenOfElement(document.getDocumentElement());
int listSize = sharedElementList.size();
for (int i = 0; i < listSize; i++) {
Element xmlElement = sharedElementList.get(i);
String key2 = xmlElement.getAttribute(TemplateEngineHelper.ID);
String value2 = xmlElement.getAttribute(TemplateEngineHelper.VALUE);
if (key.equals(key2)) {
return value2;
}
}
return null;
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
public void serialize(ICHelpInvocationContext context) {
CHelpSettings settings = getHelpSettings(context);
File file = getSettingsFile();
try {
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document doc;
Element rootElement = null;
if (file.exists()) {
doc = builder.parse(file);
NodeList nodes = doc.getElementsByTagName(ELEMENT_ROOT);
if (nodes.getLength() > 0)
rootElement = (Element) nodes.item(0);
} else {
doc = builder.newDocument();
}
if (rootElement == null) {
rootElement = doc.createElement(ELEMENT_ROOT);
doc.appendChild(rootElement);
}
settings.serialize(doc, rootElement);
FileWriter writer = new FileWriter(file);
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); //$NON-NLS-1$
transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
DOMSource source = new DOMSource(doc);
StreamResult result = new StreamResult(writer);
transformer.transform(source, result);
writer.close();
} catch (ParserConfigurationException e) {
} catch (SAXException e) {
} catch (TransformerConfigurationException e) {
} catch (TransformerException e) {
} catch (IOException e) {
}
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
private static CHelpSettings createHelpSettings(IProject project) {
// String projectName = project.getName();
File file = getSettingsFile();
CHelpSettings settings = null;
Element rootElement = null;
if (file.isFile()) {
try {
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document doc = builder.parse(file);
NodeList nodes = doc.getElementsByTagName(ELEMENT_ROOT);
if (nodes.getLength() > 0)
rootElement = (Element) nodes.item(0);
} catch (ParserConfigurationException e) {
} catch (SAXException e) {
} catch (IOException e) {
}
}
settings = new CHelpSettings(project, rootElement);
return settings;
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
private void loadFile(IConfigurationElement el, ArrayList<ICHelpBook> chbl, String pluginId) {
String fname = el.getAttribute(ATTRIB_FILE);
if (fname == null || fname.trim().length() == 0)
return;
URL x = FileLocator.find(Platform.getBundle(pluginId), new Path(fname), null);
if (x == null)
return;
try {
x = FileLocator.toFileURL(x);
} catch (IOException e) {
return;
}
fname = x.getPath();
if (fname == null || fname.trim().length() == 0)
return;
// format is not supported for now
// String format = el.getAttribute(ATTRIB_FORMAT);
Document doc = null;
try {
InputStream stream = new FileInputStream(fname);
BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
InputSource src = new InputSource(reader);
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
doc = builder.parse(src);
Element e = doc.getDocumentElement();
if (NODE_HEAD.equals(e.getNodeName())) {
NodeList list = e.getChildNodes();
for (int j = 0; j < list.getLength(); j++) {
Node node = list.item(j);
if (node.getNodeType() != Node.ELEMENT_NODE)
continue;
if (NODE_BOOK.equals(node.getNodeName())) {
chbl.add(new CHelpBook((Element) node));
}
}
}
} catch (ParserConfigurationException e) {
} catch (SAXException e) {
} catch (IOException e) {
}
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
private static void writeProfilesToStream(Collection<Profile> profiles, OutputStream stream, String encoding,
IProfileVersioner profileVersioner) throws CoreException {
try {
final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
final DocumentBuilder builder = factory.newDocumentBuilder();
final Document document = builder.newDocument();
final Element rootElement = document.createElement(XML_NODE_ROOT);
rootElement.setAttribute(XML_ATTRIBUTE_VERSION, Integer.toString(profileVersioner.getCurrentVersion()));
document.appendChild(rootElement);
for (Object element : profiles) {
final Profile profile = (Profile) element;
if (profile.isProfileToSave()) {
final Element profileElement = createProfileElement(profile, document, profileVersioner);
rootElement.appendChild(profileElement);
}
}
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
transformer.setOutputProperty(OutputKeys.ENCODING, encoding);
transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
transformer.transform(new DOMSource(document), new StreamResult(stream));
} catch (TransformerException e) {
throw createException(e, FormatterMessages.CodingStyleConfigurationBlock_error_serializing_xml_message);
} catch (ParserConfigurationException e) {
throw createException(e, FormatterMessages.CodingStyleConfigurationBlock_error_serializing_xml_message);
}
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
protected static List<Profile> readProfilesFromStream(InputSource inputSource) throws CoreException {
final ProfileDefaultHandler handler = new ProfileDefaultHandler();
try {
final SAXParserFactory factory = SAXParserFactory.newInstance();
final SAXParser parser = factory.newSAXParser();
parser.parse(inputSource, handler);
} catch (SAXException e) {
throw createException(e, FormatterMessages.CodingStyleConfigurationBlock_error_reading_xml_message);
} catch (IOException e) {
throw createException(e, FormatterMessages.CodingStyleConfigurationBlock_error_reading_xml_message);
} catch (ParserConfigurationException e) {
throw createException(e, FormatterMessages.CodingStyleConfigurationBlock_error_reading_xml_message);
}
return handler.getProfiles();
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
private static Document parse(InputStream in) throws SettingsImportExportException {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setValidating(false);
factory.setNamespaceAware(false);
factory.setIgnoringComments(true);
try {
DocumentBuilder parser = factory.newDocumentBuilder();
parser.setErrorHandler(ABORTING_ERROR_HANDER); // causes SAXException to be thrown on any parse error
InputSource input = new InputSource(in); // TODO should I be using an InputSource?
Document doc = parser.parse(input);
return doc;
} catch (Exception e) {
throw new SettingsImportExportException(e);
}
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
public static String serializeDocument(Document doc, boolean indent) throws IOException, TransformerException {
ByteArrayOutputStream s = new ByteArrayOutputStream();
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer();
transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
transformer.setOutputProperty(OutputKeys.INDENT, indent ? "yes" : "no"); //$NON-NLS-1$ //$NON-NLS-2$
DOMSource source = new DOMSource(doc);
StreamResult outputTarget = new StreamResult(s);
transformer.transform(source, outputTarget);
return s.toString("UTF8"); //$NON-NLS-1$
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
private void loadActionData() {
String actionData = CDebugCorePlugin.getDefault().getPluginPreferences().getString(BREAKPOINT_ACTION_DATA);
if (actionData == null || actionData.length() == 0)
return;
Element root = null;
DocumentBuilder parser;
try {
parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
parser.setErrorHandler(new DefaultHandler());
root = parser.parse(new InputSource(new StringReader(actionData))).getDocumentElement();
NodeList nodeList = root.getChildNodes();
int entryCount = nodeList.getLength();
for (int i = 0; i < entryCount; i++) {
Node node = nodeList.item(i);
short type = node.getNodeType();
if (type == Node.ELEMENT_NODE) {
Element subElement = (Element) node;
String nodeName = subElement.getNodeName();
if (nodeName.equalsIgnoreCase("actionEntry")) { //$NON-NLS-1$
String name = subElement.getAttribute("name"); //$NON-NLS-1$
if (name == null)
throw new Exception();
String value = subElement.getAttribute("value"); //$NON-NLS-1$
if (value == null)
throw new Exception();
String className = subElement.getAttribute("class"); //$NON-NLS-1$
if (className == null)
throw new Exception();
IBreakpointAction action = createActionFromClassName(name, className);
action.initializeFromMemento(value);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
public void saveActionData() {
String actionData = ""; //$NON-NLS-1$
DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = null;
try {
docBuilder = dfactory.newDocumentBuilder();
Document doc = docBuilder.newDocument();
Element rootElement = doc.createElement("breakpointActionData"); //$NON-NLS-1$
doc.appendChild(rootElement);
for (IBreakpointAction action : getBreakpointActions()) {
Element element = doc.createElement("actionEntry"); //$NON-NLS-1$
element.setAttribute("name", action.getName()); //$NON-NLS-1$
element.setAttribute("class", action.getClass().getName()); //$NON-NLS-1$
element.setAttribute("value", action.getMemento()); //$NON-NLS-1$
rootElement.appendChild(element);
}
ByteArrayOutputStream s = new ByteArrayOutputStream();
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer();
transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
DOMSource source = new DOMSource(doc);
StreamResult outputTarget = new StreamResult(s);
transformer.transform(source, outputTarget);
actionData = s.toString("UTF8"); //$NON-NLS-1$
} catch (Exception e) {
e.printStackTrace();
}
CDebugCorePlugin.getDefault().getPluginPreferences().setValue(BREAKPOINT_ACTION_DATA, actionData);
CDebugCorePlugin.getDefault().savePluginPreferences();
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
public String getMemento() throws CoreException {
Document document = null;
Throwable ex = null;
try {
document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
Element node = document.createElement(ELEMENT_NAME);
document.appendChild(node);
node.setAttribute(ATTR_DIRECTORY, getDirectory().toOSString());
if (getAssociation() != null)
node.setAttribute(ATTR_ASSOCIATION, getAssociation().toOSString());
node.setAttribute(ATTR_SEARCH_SUBFOLDERS, String.valueOf(searchSubfolders()));
return CDebugUtils.serializeDocument(document);
} catch (ParserConfigurationException e) {
ex = e;
} catch (IOException e) {
ex = e;
} catch (TransformerException e) {
ex = e;
}
abort(NLS.bind(InternalSourceLookupMessages.CDirectorySourceLocation_0, getDirectory().toOSString()), ex);
// execution will not reach here
return null;
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
public void initializeFrom(String memento) throws CoreException {
Exception ex = null;
try {
Element root = null;
DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
StringReader reader = new StringReader(memento);
InputSource source = new InputSource(reader);
root = parser.parse(source).getDocumentElement();
String dir = root.getAttribute(ATTR_DIRECTORY);
if (isEmpty(dir)) {
abort(InternalSourceLookupMessages.CDirectorySourceLocation_1, null);
} else {
IPath path = new Path(dir);
if (path.isValidPath(dir) && path.toFile().isDirectory() && path.toFile().exists()) {
setDirectory(path);
} else {
abort(NLS.bind(InternalSourceLookupMessages.CDirectorySourceLocation_2, dir), null);
}
}
dir = root.getAttribute(ATTR_ASSOCIATION);
if (isEmpty(dir)) {
setAssociation(null);
} else {
IPath path = new Path(dir);
if (path.isValidPath(dir)) {
setAssociation(path);
} else {
setAssociation(null);
}
}
setSearchSubfolders(Boolean.valueOf(root.getAttribute(ATTR_SEARCH_SUBFOLDERS)).booleanValue());
return;
} catch (ParserConfigurationException e) {
ex = e;
} catch (SAXException e) {
ex = e;
} catch (IOException e) {
ex = e;
}
abort(InternalSourceLookupMessages.CDirectorySourceLocation_3, ex);
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
public String getMemento() throws CoreException {
Document document = null;
Throwable ex = null;
try {
document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
Element node = document.createElement(ELEMENT_NAME);
document.appendChild(node);
node.setAttribute(ATTR_PROJECT, getProject().getName());
node.setAttribute(ATTR_GENERIC, String.valueOf(isGeneric()));
return CDebugUtils.serializeDocument(document);
} catch (ParserConfigurationException e) {
ex = e;
} catch (IOException e) {
ex = e;
} catch (TransformerException e) {
ex = e;
}
abort(NLS.bind(InternalSourceLookupMessages.CProjectSourceLocation_0, getProject().getName()), ex);
// execution will not reach here
return null;
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
public void initializeFrom(String memento) throws CoreException {
Exception ex = null;
try {
Element root = null;
DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
StringReader reader = new StringReader(memento);
InputSource source = new InputSource(reader);
root = parser.parse(source).getDocumentElement();
String name = root.getAttribute(ATTR_PROJECT);
if (isEmpty(name)) {
abort(InternalSourceLookupMessages.CProjectSourceLocation_1, null);
} else {
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
setProject(project);
}
String isGeneric = root.getAttribute(ATTR_GENERIC);
if (isGeneric == null || isGeneric.trim().length() == 0)
isGeneric = Boolean.FALSE.toString();
setGenerated(isGeneric.equals(Boolean.TRUE.toString()));
return;
} catch (ParserConfigurationException e) {
ex = e;
} catch (SAXException e) {
ex = e;
} catch (IOException e) {
ex = e;
}
abort(InternalSourceLookupMessages.CProjectSourceLocation_2, ex);
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
public void initializeFromMemento(String memento) throws CoreException {
Exception ex = null;
try {
Element root = null;
DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
StringReader reader = new StringReader(memento);
InputSource source = new InputSource(reader);
root = parser.parse(source).getDocumentElement();
if (!root.getNodeName().equalsIgnoreCase(SOURCE_LOCATOR_NAME)) {
abort(InternalSourceLookupMessages.CSourceLocator_1, null);
}
List<ICSourceLocation> sourceLocations = new ArrayList<>();
// Add locations based on referenced projects
IProject project = getProject();
if (project != null && project.exists() && project.isOpen())
sourceLocations.addAll(Arrays.asList(getDefaultSourceLocations()));
removeDisabledLocations(root, sourceLocations);
addAdditionalLocations(root, sourceLocations);
// To support old launch configuration
addOldLocations(root, sourceLocations);
setSourceLocations(sourceLocations.toArray(new ICSourceLocation[sourceLocations.size()]));
setSearchForDuplicateFiles(Boolean.valueOf(root.getAttribute(ATTR_DUPLICATE_FILES)).booleanValue());
return;
} catch (ParserConfigurationException e) {
ex = e;
} catch (SAXException e) {
ex = e;
} catch (IOException e) {
ex = e;
}
abort(InternalSourceLookupMessages.CSourceLocator_2, ex);
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
public String getMemento() throws CoreException {
Document document = null;
Throwable ex = null;
try {
document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
Element node = document.createElement(SOURCE_LOCATOR_NAME);
document.appendChild(node);
ICSourceLocation[] locations = getSourceLocations();
saveDisabledGenericSourceLocations(locations, document, node);
saveAdditionalSourceLocations(locations, document, node);
node.setAttribute(ATTR_DUPLICATE_FILES, String.valueOf(searchForDuplicateFiles()));
return CDebugUtils.serializeDocument(document);
} catch (ParserConfigurationException e) {
ex = e;
} catch (IOException e) {
ex = e;
} catch (TransformerException e) {
ex = e;
}
abort(InternalSourceLookupMessages.CSourceLocator_0, ex);
// execution will not reach here
return null;
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
public static ICSourceLocation[] getCommonSourceLocationsFromMemento(String memento) {
ICSourceLocation[] result = new ICSourceLocation[0];
if (!isEmpty(memento)) {
try {
DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
StringReader reader = new StringReader(memento);
InputSource source = new InputSource(reader);
Element root = parser.parse(source).getDocumentElement();
if (root.getNodeName().equalsIgnoreCase(NAME_COMMON_SOURCE_LOCATIONS))
result = initializeSourceLocations(root);
} catch (ParserConfigurationException e) {
CDebugCorePlugin.log(new Status(IStatus.ERROR, CDebugCorePlugin.getUniqueIdentifier(), 0,
"Error initializing common source settings.", e)); //$NON-NLS-1$
} catch (SAXException e) {
CDebugCorePlugin.log(new Status(IStatus.ERROR, CDebugCorePlugin.getUniqueIdentifier(), 0,
"Error initializing common source settings.", e)); //$NON-NLS-1$
} catch (IOException e) {
CDebugCorePlugin.log(new Status(IStatus.ERROR, CDebugCorePlugin.getUniqueIdentifier(), 0,
"Error initializing common source settings.", e)); //$NON-NLS-1$
}
}
return result;
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
public static String getCommonSourceLocationsMemento(ICSourceLocation[] locations) {
Document document = null;
Throwable ex = null;
try {
document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
Element element = document.createElement(NAME_COMMON_SOURCE_LOCATIONS);
document.appendChild(element);
saveSourceLocations(document, element, locations);
return CDebugUtils.serializeDocument(document);
} catch (ParserConfigurationException e) {
ex = e;
} catch (IOException e) {
ex = e;
} catch (TransformerException e) {
ex = e;
}
CDebugCorePlugin.log(new Status(IStatus.ERROR, CDebugCorePlugin.getUniqueIdentifier(), 0,
"Error saving common source settings.", ex)); //$NON-NLS-1$
return null;
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
public String getMemento() {
String executeData = ""; //$NON-NLS-1$
if (externalToolName != null) {
DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = null;
try {
docBuilder = dfactory.newDocumentBuilder();
Document doc = docBuilder.newDocument();
Element rootElement = doc.createElement("launchConfigName"); //$NON-NLS-1$
rootElement.setAttribute("configName", externalToolName); //$NON-NLS-1$
doc.appendChild(rootElement);
ByteArrayOutputStream s = new ByteArrayOutputStream();
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer();
transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
DOMSource source = new DOMSource(doc);
StreamResult outputTarget = new StreamResult(s);
transformer.transform(source, outputTarget);
executeData = s.toString("UTF8"); //$NON-NLS-1$
} catch (Exception e) {
e.printStackTrace();
}
}
return executeData;
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
public void initializeFromMemento(String data) {
Element root = null;
DocumentBuilder parser;
try {
parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
parser.setErrorHandler(new DefaultHandler());
root = parser.parse(new InputSource(new StringReader(data))).getDocumentElement();
String value = root.getAttribute("configName"); //$NON-NLS-1$
if (value == null)
throw new Exception();
externalToolName = value;
} catch (Exception e) {
e.printStackTrace();
}
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
public String getMemento() {
String logData = ""; //$NON-NLS-1$
DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = null;
try {
docBuilder = dfactory.newDocumentBuilder();
Document doc = docBuilder.newDocument();
Element rootElement = doc.createElement("logData"); //$NON-NLS-1$
rootElement.setAttribute("message", message); //$NON-NLS-1$
rootElement.setAttribute("evalExpr", Boolean.toString(evaluateExpression)); //$NON-NLS-1$
doc.appendChild(rootElement);
ByteArrayOutputStream s = new ByteArrayOutputStream();
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer();
transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
DOMSource source = new DOMSource(doc);
StreamResult outputTarget = new StreamResult(s);
transformer.transform(source, outputTarget);
logData = s.toString("UTF8"); //$NON-NLS-1$
} catch (Exception e) {
e.printStackTrace();
}
return logData;
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
public void initializeFromMemento(String data) {
Element root = null;
DocumentBuilder parser;
try {
parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
parser.setErrorHandler(new DefaultHandler());
root = parser.parse(new InputSource(new StringReader(data))).getDocumentElement();
String value = root.getAttribute("message"); //$NON-NLS-1$
if (value == null)
throw new Exception();
message = value;
value = root.getAttribute("evalExpr"); //$NON-NLS-1$
if (value == null)
throw new Exception();
evaluateExpression = Boolean.valueOf(value).booleanValue();
value = root.getAttribute("resume"); //$NON-NLS-1$
if (value == null)
throw new Exception();
} catch (Exception e) {
e.printStackTrace();
}
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
public void initializeFromMemento(String data) {
Element root = null;
DocumentBuilder parser;
try {
parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
parser.setErrorHandler(new DefaultHandler());
root = parser.parse(new InputSource(new StringReader(data))).getDocumentElement();
String value = root.getAttribute("pauseTime"); //$NON-NLS-1$
if (value == null)
throw new Exception();
pauseTime = Integer.parseInt(value);
} catch (Exception e) {
e.printStackTrace();
}
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
public String getMemento() {
String resumeData = ""; //$NON-NLS-1$
DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = null;
try {
docBuilder = dfactory.newDocumentBuilder();
Document doc = docBuilder.newDocument();
Element rootElement = doc.createElement("resumeData"); //$NON-NLS-1$
rootElement.setAttribute("pauseTime", Integer.toString(pauseTime)); //$NON-NLS-1$
doc.appendChild(rootElement);
ByteArrayOutputStream s = new ByteArrayOutputStream();
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer();
transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
DOMSource source = new DOMSource(doc);
StreamResult outputTarget = new StreamResult(s);
transformer.transform(source, outputTarget);
resumeData = s.toString("UTF8"); //$NON-NLS-1$
} catch (Exception e) {
e.printStackTrace();
}
return resumeData;
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
public void initializeFromMemento(String data) {
Element root = null;
DocumentBuilder parser;
try {
parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
parser.setErrorHandler(new DefaultHandler());
root = parser.parse(new InputSource(new StringReader(data))).getDocumentElement();
String value = root.getAttribute("operation"); //$NON-NLS-1$
if (value == null)
throw new Exception();
fOperation = REVERSE_DEBUG_ACTIONS_ENUM.valueOf(value);
} catch (Exception e) {
e.printStackTrace();
}
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
public String getMemento() {
String reverseDebugData = ""; //$NON-NLS-1$
DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = null;
try {
docBuilder = dfactory.newDocumentBuilder();
Document doc = docBuilder.newDocument();
Element rootElement = doc.createElement("reverseDebugData"); //$NON-NLS-1$
rootElement.setAttribute("operation", fOperation.toString()); //$NON-NLS-1$
doc.appendChild(rootElement);
ByteArrayOutputStream s = new ByteArrayOutputStream();
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer();
transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
DOMSource source = new DOMSource(doc);
StreamResult outputTarget = new StreamResult(s);
transformer.transform(source, outputTarget);
reverseDebugData = s.toString("UTF8"); //$NON-NLS-1$
} catch (Exception e) {
e.printStackTrace();
}
return reverseDebugData;
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
public String getMemento() {
String soundData = ""; //$NON-NLS-1$
if (soundFile != null) {
DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = null;
try {
docBuilder = dfactory.newDocumentBuilder();
Document doc = docBuilder.newDocument();
Element rootElement = doc.createElement("soundData"); //$NON-NLS-1$
rootElement.setAttribute("file", soundFile.getAbsolutePath()); //$NON-NLS-1$
doc.appendChild(rootElement);
ByteArrayOutputStream s = new ByteArrayOutputStream();
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer();
transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
DOMSource source = new DOMSource(doc);
StreamResult outputTarget = new StreamResult(s);
transformer.transform(source, outputTarget);
soundData = s.toString("UTF8"); //$NON-NLS-1$
} catch (Exception e) {
e.printStackTrace();
}
}
return soundData;
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
public void initializeFromMemento(String data) {
Element root = null;
DocumentBuilder parser;
try {
parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
parser.setErrorHandler(new DefaultHandler());
root = parser.parse(new InputSource(new StringReader(data))).getDocumentElement();
String value = root.getAttribute("file"); //$NON-NLS-1$
if (value == null)
throw new Exception();
soundFile = new File(value);
} catch (Exception e) {
e.printStackTrace();
}
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
private void loadRecentSounds() {
String recentSoundData = CDebugUIPlugin.getDefault().getPreferenceStore().getString(SOUND_ACTION_RECENT);
if (recentSoundData == null || recentSoundData.length() == 0) {
initializeRecentSounds();
return;
}
recentSounds = new ArrayList<>();
Element root = null;
DocumentBuilder parser;
try {
parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
parser.setErrorHandler(new DefaultHandler());
root = parser.parse(new InputSource(new StringReader(recentSoundData))).getDocumentElement();
NodeList nodeList = root.getChildNodes();
int entryCount = nodeList.getLength();
for (int i = 0; i < entryCount; i++) {
Node node = nodeList.item(i);
short type = node.getNodeType();
if (type == Node.ELEMENT_NODE) {
Element subElement = (Element) node;
String nodeName = subElement.getNodeName();
if (nodeName.equalsIgnoreCase("soundFileName")) { //$NON-NLS-1$
String value = subElement.getAttribute("name"); //$NON-NLS-1$
if (value == null)
throw new Exception();
File soundFile = new File(value);
if (soundFile.exists()) {
recentSounds.add(soundFile);
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
if (recentSounds.size() == 0)
initializeRecentSounds();
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
public void saveRecentSounds() {
String recentSoundData = ""; //$NON-NLS-1$
DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = null;
try {
docBuilder = dfactory.newDocumentBuilder();
Document doc = docBuilder.newDocument();
Element rootElement = doc.createElement("recentSounds"); //$NON-NLS-1$
doc.appendChild(rootElement);
for (Iterator<File> iter = recentSounds.iterator(); iter.hasNext();) {
File soundFile = iter.next();
Element element = doc.createElement("soundFileName"); //$NON-NLS-1$
element.setAttribute("name", soundFile.getAbsolutePath()); //$NON-NLS-1$
rootElement.appendChild(element);
}
ByteArrayOutputStream s = new ByteArrayOutputStream();
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer();
transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
DOMSource source = new DOMSource(doc);
StreamResult outputTarget = new StreamResult(s);
transformer.transform(source, outputTarget);
recentSoundData = s.toString("UTF8"); //$NON-NLS-1$
} catch (Exception e) {
e.printStackTrace();
}
CDebugUIPlugin.getDefault().getPreferenceStore().setValue(SOUND_ACTION_RECENT, recentSoundData);
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
public void initializeFromMemento(String memento) throws CoreException {
Exception ex = null;
try {
Element root = null;
DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
StringReader reader = new StringReader(memento);
InputSource source = new InputSource(reader);
root = parser.parse(source).getDocumentElement();
if (!root.getNodeName().equalsIgnoreCase(ELEMENT_NAME)) {
abort(SourceLookupMessages.getString("OldDefaultSourceLocator.2"), null); //$NON-NLS-1$
}
String projectName = root.getAttribute(ATTR_PROJECT);
String data = root.getAttribute(ATTR_MEMENTO);
if (isEmpty(projectName)) {
abort(SourceLookupMessages.getString("OldDefaultSourceLocator.3"), null); //$NON-NLS-1$
}
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
if (getCSourceLocator() == null)
setCSourceLocator(SourceLookupFactory.createSourceLocator(project));
if (getCSourceLocator().getProject() != null && !getCSourceLocator().getProject().equals(project))
return;
if (project == null || !project.exists() || !project.isOpen())
abort(MessageFormat.format(SourceLookupMessages.getString("OldDefaultSourceLocator.4"), //$NON-NLS-1$
new Object[] { projectName }), null);
IPersistableSourceLocator psl = getPersistableSourceLocator();
if (psl != null)
psl.initializeFromMemento(data);
else
abort(SourceLookupMessages.getString("OldDefaultSourceLocator.5"), null); //$NON-NLS-1$
return;
} catch (ParserConfigurationException e) {
ex = e;
} catch (SAXException e) {
ex = e;
} catch (IOException e) {
ex = e;
}
abort(SourceLookupMessages.getString("OldDefaultSourceLocator.6"), ex); //$NON-NLS-1$
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
public String getMemento() throws CoreException {
if (getCSourceLocator() != null) {
Document document = null;
Throwable ex = null;
try {
document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
Element element = document.createElement(ELEMENT_NAME);
document.appendChild(element);
element.setAttribute(ATTR_PROJECT, getCSourceLocator().getProject().getName());
IPersistableSourceLocator psl = getPersistableSourceLocator();
if (psl != null) {
element.setAttribute(ATTR_MEMENTO, psl.getMemento());
}
return CDebugUtils.serializeDocument(document);
} catch (ParserConfigurationException e) {
ex = e;
} catch (IOException e) {
ex = e;
} catch (TransformerException e) {
ex = e;
}
abort(SourceLookupMessages.getString("OldDefaultSourceLocator.1"), ex); //$NON-NLS-1$
}
return null;
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
public static Map<String, String> decodeMapFromMemento(String memento) {
Map<String, String> keyPairValues = new HashMap<>();
Element root = null;
DocumentBuilder parser;
try {
parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
parser.setErrorHandler(new DefaultHandler());
root = parser.parse(new InputSource(new StringReader(memento))).getDocumentElement();
NodeList nodeList = root.getChildNodes();
for (int i = 0; i < nodeList.getLength(); i++) {
Node node = nodeList.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
Element elem = (Element) node;
NamedNodeMap nodeMap = elem.getAttributes();
String key = null;
String value = null;
for (int idx = 0; idx < nodeMap.getLength(); idx++) {
Node attrNode = nodeMap.item(idx);
if (attrNode.getNodeType() == Node.ATTRIBUTE_NODE) {
Attr attr = (Attr) attrNode;
if (attr.getName().equals(ATTRIBUTE_KEY)) {
key = attr.getValue();
} else if (attr.getName().equals(ATTRIBUTE_VALUE)) {
value = attr.getValue();
}
}
}
if (key != null && value != null) {
keyPairValues.put(key, value);
} else {
throw new Exception();
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return keyPairValues;
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
public static List<String> decodeListFromMemento(String memento) {
List<String> list = new ArrayList<>();
Element root = null;
DocumentBuilder parser;
try {
parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
parser.setErrorHandler(new DefaultHandler());
root = parser.parse(new InputSource(new StringReader(memento))).getDocumentElement();
NodeList nodeList = root.getChildNodes();
for (int i = 0; i < nodeList.getLength(); i++) {
Node node = nodeList.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
Element elem = (Element) node;
String value = elem.getAttribute(ATTRIBUTE_VALUE);
if (value != null) {
list.add(value);
} else {
throw new Exception();
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return list;
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
public static String encodeListIntoMemento(List<String> labels) {
String returnValue = null;
DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = null;
try {
docBuilder = dfactory.newDocumentBuilder();
Document doc = docBuilder.newDocument();
Element rootElement = doc.createElement(ROOT_ELEMENT_TAGNAME);
doc.appendChild(rootElement);
// create one XML element per list entry to save
for (String lbl : labels) {
Element elem = doc.createElement(ELEMENT_TAGNAME);
elem.setAttribute(ATTRIBUTE_VALUE, lbl);
rootElement.appendChild(elem);
}
ByteArrayOutputStream s = new ByteArrayOutputStream();
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer();
transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
DOMSource source = new DOMSource(doc);
StreamResult outputTarget = new StreamResult(s);
transformer.transform(source, outputTarget);
returnValue = s.toString("UTF8"); //$NON-NLS-1$
} catch (Exception e) {
e.printStackTrace();
}
return returnValue;
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
public static String encodeMapIntoMemento(Map<String, String> keyPairValues) {
String returnValue = null;
DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = null;
try {
docBuilder = dfactory.newDocumentBuilder();
Document doc = docBuilder.newDocument();
Element rootElement = doc.createElement(ROOT_ELEMENT_TAGNAME);
doc.appendChild(rootElement);
// create one XML element per map entry
for (String key : keyPairValues.keySet()) {
Element elem = doc.createElement(ELEMENT_TAGNAME);
// store key and value as values of 2 attributes
elem.setAttribute(ATTRIBUTE_KEY, key);
elem.setAttribute(ATTRIBUTE_VALUE, keyPairValues.get(key));
rootElement.appendChild(elem);
}
ByteArrayOutputStream s = new ByteArrayOutputStream();
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer();
transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
DOMSource source = new DOMSource(doc);
StreamResult outputTarget = new StreamResult(s);
transformer.transform(source, outputTarget);
returnValue = s.toString("UTF8"); //$NON-NLS-1$
} catch (Exception e) {
e.printStackTrace();
}
return returnValue;
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
public void initializeFromMemento(String data) {
Element root = null;
DocumentBuilder parser;
try {
parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
parser.setErrorHandler(new DefaultHandler());
root = parser.parse(new InputSource(new StringReader(data))).getDocumentElement();
fCollectString = root.getAttribute(COLLECT_STRING_ATTR);
if (fCollectString == null)
fCollectString = ""; //$NON-NLS-1$
String asStrings = root.getAttribute(COLLECT_AS_STRING_ATTR);
if (asStrings != null) {
fCharPtrAsStrings = Boolean.valueOf(asStrings);
} else {
fCharPtrAsStrings = false;
}
fCharPtrAsStringsLimit = null;
String asStringsLimit = root.getAttribute(COLLECT_AS_STRING_LIMIT_ATTR);
if (asStringsLimit != null) {
try {
fCharPtrAsStringsLimit = Integer.valueOf(asStringsLimit);
} catch (NumberFormatException e) {
// leave as null to disable
}
}
} catch (Exception e) {
GdbPlugin.log(e);
}
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
public String getMemento() {
String collectData = ""; //$NON-NLS-1$
DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = null;
try {
docBuilder = dfactory.newDocumentBuilder();
Document doc = docBuilder.newDocument();
Element rootElement = doc.createElement(COLLECT_ACTION_ELEMENT_NAME);
// Store the different attributes of this collect action
rootElement.setAttribute(COLLECT_STRING_ATTR, fCollectString);
rootElement.setAttribute(COLLECT_AS_STRING_ATTR, Boolean.toString(fCharPtrAsStrings));
rootElement.setAttribute(COLLECT_AS_STRING_LIMIT_ATTR,
fCharPtrAsStringsLimit == null ? "" : fCharPtrAsStringsLimit.toString()); //$NON-NLS-1$
doc.appendChild(rootElement);
ByteArrayOutputStream s = new ByteArrayOutputStream();
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer();
transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
DOMSource source = new DOMSource(doc);
StreamResult outputTarget = new StreamResult(s);
transformer.transform(source, outputTarget);
collectData = s.toString("UTF8"); //$NON-NLS-1$
} catch (Exception e) {
GdbPlugin.log(e);
}
return collectData;
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
public void initializeFromMemento(String data) {
Element root = null;
DocumentBuilder parser;
try {
parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
parser.setErrorHandler(new DefaultHandler());
root = parser.parse(new InputSource(new StringReader(data))).getDocumentElement();
fEvalString = root.getAttribute("evalString"); //$NON-NLS-1$
if (fEvalString == null)
throw new Exception();
} catch (Exception e) {
GdbPlugin.log(e);
}
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
public String getMemento() {
String collectData = ""; //$NON-NLS-1$
DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = null;
try {
docBuilder = dfactory.newDocumentBuilder();
Document doc = docBuilder.newDocument();
Element rootElement = doc.createElement("evalData"); //$NON-NLS-1$
rootElement.setAttribute("evalString", fEvalString); //$NON-NLS-1$
doc.appendChild(rootElement);
ByteArrayOutputStream s = new ByteArrayOutputStream();
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer();
transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
DOMSource source = new DOMSource(doc);
StreamResult outputTarget = new StreamResult(s);
transformer.transform(source, outputTarget);
collectData = s.toString("UTF8"); //$NON-NLS-1$
} catch (Exception e) {
GdbPlugin.log(e);
}
return collectData;
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
private void loadActionData() {
String actionData = GdbPlugin.getDefault().getPluginPreferences().getString(TRACEPOINT_ACTION_DATA);
if (actionData == null || actionData.length() == 0)
return;
Element root = null;
DocumentBuilder parser;
try {
parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
parser.setErrorHandler(new DefaultHandler());
root = parser.parse(new InputSource(new StringReader(actionData))).getDocumentElement();
NodeList nodeList = root.getChildNodes();
int entryCount = nodeList.getLength();
for (int i = 0; i < entryCount; i++) {
Node node = nodeList.item(i);
short type = node.getNodeType();
if (type == Node.ELEMENT_NODE) {
Element subElement = (Element) node;
String nodeName = subElement.getNodeName();
if (nodeName.equalsIgnoreCase("actionEntry")) { //$NON-NLS-1$
String name = subElement.getAttribute("name"); //$NON-NLS-1$
if (name == null)
throw new Exception();
String value = subElement.getAttribute("value"); //$NON-NLS-1$
if (value == null)
throw new Exception();
String className = subElement.getAttribute("class"); //$NON-NLS-1$
if (className == null)
throw new Exception();
ITracepointAction action = (ITracepointAction) Class.forName(className).newInstance();
action.setName(name);
action.initializeFromMemento(value);
addAction(action);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
public void saveActionData() {
String actionData = ""; //$NON-NLS-1$
DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = null;
try {
docBuilder = dfactory.newDocumentBuilder();
Document doc = docBuilder.newDocument();
Element rootElement = doc.createElement("tracepointActionData"); //$NON-NLS-1$
doc.appendChild(rootElement);
for (Iterator<ITracepointAction> iter = getActions().iterator(); iter.hasNext();) {
ITracepointAction action = iter.next();
Element element = doc.createElement("actionEntry"); //$NON-NLS-1$
element.setAttribute("name", action.getName()); //$NON-NLS-1$
element.setAttribute("class", action.getClass().getName()); //$NON-NLS-1$
element.setAttribute("value", action.getMemento()); //$NON-NLS-1$
rootElement.appendChild(element);
}
ByteArrayOutputStream s = new ByteArrayOutputStream();
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer();
transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
DOMSource source = new DOMSource(doc);
StreamResult outputTarget = new StreamResult(s);
transformer.transform(source, outputTarget);
actionData = s.toString("UTF8"); //$NON-NLS-1$
} catch (Exception e) {
e.printStackTrace();
}
GdbPlugin.getDefault().getPluginPreferences().setValue(TRACEPOINT_ACTION_DATA, actionData);
GdbPlugin.getDefault().savePluginPreferences();
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
public String getMemento() {
String collectData = ""; //$NON-NLS-1$
DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = null;
try {
docBuilder = dfactory.newDocumentBuilder();
Document doc = docBuilder.newDocument();
Element rootElement = doc.createElement("whileSteppingData"); //$NON-NLS-1$
rootElement.setAttribute("whileSteppingCount", Integer.toString(fStepCount)); //$NON-NLS-1$
rootElement.setAttribute("subActionNames", fSubActionNames); //$NON-NLS-1$
doc.appendChild(rootElement);
ByteArrayOutputStream s = new ByteArrayOutputStream();
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer();
transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
DOMSource source = new DOMSource(doc);
StreamResult outputTarget = new StreamResult(s);
transformer.transform(source, outputTarget);
collectData = s.toString("UTF8"); //$NON-NLS-1$
} catch (Exception e) {
GdbPlugin.log(e);
}
return collectData;
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
public void initializeFromMemento(String data) {
Element root = null;
DocumentBuilder parser;
try {
parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
parser.setErrorHandler(new DefaultHandler());
root = parser.parse(new InputSource(new StringReader(data))).getDocumentElement();
setStepCount(Integer.parseInt(root.getAttribute("whileSteppingCount"))); //$NON-NLS-1$
setSubActionsNames(root.getAttribute("subActionNames")); //$NON-NLS-1$
if (fSubActionNames == null)
throw new Exception();
setSubActionsContent(fSubActionNames);
} catch (Exception e) {
GdbPlugin.log(e);
}
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
public void run(ITestModelUpdater modelUpdater, InputStream inputStream) throws TestingException {
try {
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
sp.parse(inputStream, new BoostXmlLogHandler(modelUpdater));
} catch (IOException e) {
throw new TestingException(
getErrorText(BoostTestsRunnerMessages.BoostTestsRunner_io_error_prefix, e.getLocalizedMessage()));
} catch (NumberFormatException e) {
throw new TestingException(
getErrorText(BoostTestsRunnerMessages.BoostTestsRunner_xml_error_prefix, e.getLocalizedMessage()));
} catch (ParserConfigurationException e) {
throw new TestingException(
getErrorText(BoostTestsRunnerMessages.BoostTestsRunner_xml_error_prefix, e.getLocalizedMessage()));
} catch (SAXException e) {
throw new TestingException(
getErrorText(BoostTestsRunnerMessages.BoostTestsRunner_xml_error_prefix, e.getLocalizedMessage()));
}
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
public void run(ITestModelUpdater modelUpdater, InputStream inputStream) throws TestingException {
try {
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
sp.parse(inputStream, new QtXmlLogHandler(modelUpdater));
} catch (IOException e) {
throw new TestingException(
getErrorText(QtTestsRunnerMessages.QtTestsRunner_io_error_prefix, e.getLocalizedMessage()));
} catch (ParserConfigurationException e) {
throw new TestingException(
getErrorText(QtTestsRunnerMessages.QtTestsRunner_xml_error_prefix, e.getLocalizedMessage()));
} catch (SAXException e) {
throw new TestingException(
getErrorText(QtTestsRunnerMessages.QtTestsRunner_xml_error_prefix, e.getLocalizedMessage()));
}
} | 0 | Java | CWE-611 | Improper Restriction of XML External Entity Reference | The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. | https://cwe.mitre.org/data/definitions/611.html | vulnerable |
protected Class<?> resolveProxyClass(String[] interfaces) throws IOException, ClassNotFoundException {
List<Class<?>> loadedClasses = new ArrayList<Class<?>>(interfaces.length);
for (String name : interfaces) {
Class<?> clazz = Class.forName(name, false, classLoader);
loadedClasses.add(clazz);
}
return Proxy.getProxyClass(classLoader, loadedClasses.toArray(new Class[loadedClasses.size()]));
} | 0 | Java | CWE-502 | Deserialization of Untrusted Data | The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid. | https://cwe.mitre.org/data/definitions/502.html | vulnerable |
private final Decoder<Object> decoder = new Decoder<Object>() {
@Override
public Object decode(ByteBuf buf, State state) throws IOException {
try {
//set thread context class loader to be the classLoader variable as there could be reflection
//done while reading from input stream which reflection will use thread class loader to load classes on demand
ClassLoader currentThreadClassLoader = Thread.currentThread().getContextClassLoader();
try {
ByteBufInputStream in = new ByteBufInputStream(buf);
ObjectInputStream inputStream;
if (classLoader != null) {
Thread.currentThread().setContextClassLoader(classLoader);
inputStream = new CustomObjectInputStream(classLoader, in);
} else {
inputStream = new ObjectInputStream(in);
}
return inputStream.readObject();
} finally {
Thread.currentThread().setContextClassLoader(currentThreadClassLoader);
}
} catch (IOException e) {
throw e;
} catch (Exception e) {
throw new IOException(e);
}
}
}; | 0 | Java | CWE-502 | Deserialization of Untrusted Data | The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid. | https://cwe.mitre.org/data/definitions/502.html | vulnerable |
protected synchronized FrameHandlerFactory createFrameHandlerFactory() throws IOException {
if(nio) {
if(this.frameHandlerFactory == null) {
if(this.nioParams.getNioExecutor() == null && this.nioParams.getThreadFactory() == null) {
this.nioParams.setThreadFactory(getThreadFactory());
}
this.frameHandlerFactory = new SocketChannelFrameHandlerFactory(connectionTimeout, nioParams, isSSL(), sslContextFactory);
}
return this.frameHandlerFactory;
} else {
return new SocketFrameHandlerFactory(connectionTimeout, socketFactory, socketConf, isSSL(), this.shutdownExecutor, sslContextFactory);
}
} | 0 | Java | CWE-400 | Uncontrolled Resource Consumption | The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources. | https://cwe.mitre.org/data/definitions/400.html | vulnerable |
public void handleFrame(Frame frame) throws IOException {
AMQCommand command = _command;
if (command.handleFrame(frame)) { // a complete command has rolled off the assembly line
_command = new AMQCommand(); // prepare for the next one
handleCompleteInboundCommand(command);
}
} | 0 | Java | CWE-400 | Uncontrolled Resource Consumption | The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources. | https://cwe.mitre.org/data/definitions/400.html | vulnerable |
public AMQCommand(com.rabbitmq.client.Method method) {
this(method, null, null);
} | 0 | Java | CWE-400 | Uncontrolled Resource Consumption | The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources. | https://cwe.mitre.org/data/definitions/400.html | vulnerable |
public AMQCommand() {
this(null, null, null);
} | 0 | Java | CWE-400 | Uncontrolled Resource Consumption | The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources. | https://cwe.mitre.org/data/definitions/400.html | vulnerable |
public AMQCommand(com.rabbitmq.client.Method method, AMQContentHeader contentHeader, byte[] body) {
this.assembler = new CommandAssembler((Method) method, contentHeader, body);
} | 0 | Java | CWE-400 | Uncontrolled Resource Consumption | The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources. | https://cwe.mitre.org/data/definitions/400.html | vulnerable |
protected AbstractFrameHandlerFactory(int connectionTimeout, SocketConfigurator configurator, boolean ssl) {
this.connectionTimeout = connectionTimeout;
this.configurator = configurator;
this.ssl = ssl;
} | 0 | Java | CWE-400 | Uncontrolled Resource Consumption | The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources. | https://cwe.mitre.org/data/definitions/400.html | vulnerable |
public CommandAssembler(Method method, AMQContentHeader contentHeader, byte[] body) {
this.method = method;
this.contentHeader = contentHeader;
this.bodyN = new ArrayList<byte[]>(2);
this.bodyLength = 0;
this.remainingBodyBytes = 0;
appendBodyFragment(body);
if (method == null) {
this.state = CAState.EXPECTING_METHOD;
} else if (contentHeader == null) {
this.state = method.hasContent() ? CAState.EXPECTING_CONTENT_HEADER : CAState.COMPLETE;
} else {
this.remainingBodyBytes = contentHeader.getBodySize() - this.bodyLength;
updateContentBodyState();
}
} | 0 | Java | CWE-400 | Uncontrolled Resource Consumption | The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources. | https://cwe.mitre.org/data/definitions/400.html | vulnerable |
private void consumeHeaderFrame(Frame f) throws IOException {
if (f.type == AMQP.FRAME_HEADER) {
this.contentHeader = AMQImpl.readContentHeaderFrom(f.getInputStream());
this.remainingBodyBytes = this.contentHeader.getBodySize();
updateContentBodyState();
} else {
throw new UnexpectedFrameError(f, AMQP.FRAME_HEADER);
}
} | 0 | Java | CWE-400 | Uncontrolled Resource Consumption | The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources. | https://cwe.mitre.org/data/definitions/400.html | vulnerable |
public static Frame readFrom(DataInputStream is) throws IOException {
int type;
int channel;
try {
type = is.readUnsignedByte();
} catch (SocketTimeoutException ste) {
// System.err.println("Timed out waiting for a frame.");
return null; // failed
}
if (type == 'A') {
/*
* Probably an AMQP.... header indicating a version
* mismatch.
*/
/*
* Otherwise meaningless, so try to read the version,
* and throw an exception, whether we read the version
* okay or not.
*/
protocolVersionMismatch(is);
}
channel = is.readUnsignedShort();
int payloadSize = is.readInt();
byte[] payload = new byte[payloadSize];
is.readFully(payload);
int frameEndMarker = is.readUnsignedByte();
if (frameEndMarker != AMQP.FRAME_END) {
throw new MalformedFrameException("Bad frame end marker: " + frameEndMarker);
}
return new Frame(type, channel, payload);
} | 0 | Java | CWE-400 | Uncontrolled Resource Consumption | The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources. | https://cwe.mitre.org/data/definitions/400.html | vulnerable |
public SocketFrameHandler(Socket socket, ExecutorService shutdownExecutor) throws IOException {
_socket = socket;
_shutdownExecutor = shutdownExecutor;
_inputStream = new DataInputStream(new BufferedInputStream(socket.getInputStream()));
_outputStream = new DataOutputStream(new BufferedOutputStream(socket.getOutputStream()));
} | 0 | Java | CWE-400 | Uncontrolled Resource Consumption | The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources. | https://cwe.mitre.org/data/definitions/400.html | vulnerable |
public Frame readFrame() throws IOException {
synchronized (_inputStream) {
return Frame.readFrom(_inputStream);
}
} | 0 | Java | CWE-400 | Uncontrolled Resource Consumption | The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources. | https://cwe.mitre.org/data/definitions/400.html | vulnerable |
public SocketFrameHandler(Socket socket) throws IOException {
this(socket, null);
} | 0 | Java | CWE-400 | Uncontrolled Resource Consumption | The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources. | https://cwe.mitre.org/data/definitions/400.html | vulnerable |
public SocketFrameHandlerFactory(int connectionTimeout, SocketFactory socketFactory, SocketConfigurator configurator,
boolean ssl, ExecutorService shutdownExecutor) {
this(connectionTimeout, socketFactory, configurator, ssl, shutdownExecutor, null);
} | 0 | Java | CWE-400 | Uncontrolled Resource Consumption | The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources. | https://cwe.mitre.org/data/definitions/400.html | vulnerable |
public FrameHandler create(Socket sock) throws IOException
{
return new SocketFrameHandler(sock, this.shutdownExecutor);
} | 0 | Java | CWE-400 | Uncontrolled Resource Consumption | The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources. | https://cwe.mitre.org/data/definitions/400.html | vulnerable |
public SocketFrameHandlerFactory(int connectionTimeout, SocketFactory socketFactory, SocketConfigurator configurator,
boolean ssl, ExecutorService shutdownExecutor, SslContextFactory sslContextFactory) {
super(connectionTimeout, configurator, ssl);
this.socketFactory = socketFactory;
this.shutdownExecutor = shutdownExecutor;
this.sslContextFactory = sslContextFactory;
} | 0 | Java | CWE-400 | Uncontrolled Resource Consumption | The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources. | https://cwe.mitre.org/data/definitions/400.html | vulnerable |
public FrameBuilder(ReadableByteChannel channel, ByteBuffer buffer) {
this.channel = channel;
this.applicationBuffer = buffer;
} | 0 | Java | CWE-400 | Uncontrolled Resource Consumption | The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources. | https://cwe.mitre.org/data/definitions/400.html | vulnerable |
public SocketChannelFrameHandlerFactory(int connectionTimeout, NioParams nioParams, boolean ssl, SslContextFactory sslContextFactory) {
super(connectionTimeout, null, ssl);
this.nioParams = new NioParams(nioParams);
this.sslContextFactory = sslContextFactory;
this.nioLoopContexts = new ArrayList<>(this.nioParams.getNbIoThreads());
for (int i = 0; i < this.nioParams.getNbIoThreads(); i++) {
this.nioLoopContexts.add(new NioLoopContext(this, this.nioParams));
}
} | 0 | Java | CWE-400 | Uncontrolled Resource Consumption | The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources. | https://cwe.mitre.org/data/definitions/400.html | vulnerable |
public SocketChannelFrameHandlerState(SocketChannel channel, NioLoopContext nioLoopsState, NioParams nioParams, SSLEngine sslEngine) {
this.channel = channel;
this.readSelectorState = nioLoopsState.readSelectorState;
this.writeSelectorState = nioLoopsState.writeSelectorState;
NioContext nioContext = new NioContext(nioParams, sslEngine);
this.writeQueue = nioParams.getWriteQueueFactory() == null ?
NioParams.DEFAULT_WRITE_QUEUE_FACTORY.apply(nioContext) :
nioParams.getWriteQueueFactory().apply(nioContext);
this.sslEngine = sslEngine;
if(this.sslEngine == null) {
this.ssl = false;
this.plainOut = nioLoopsState.writeBuffer;
this.cipherOut = null;
this.plainIn = nioLoopsState.readBuffer;
this.cipherIn = null;
this.outputStream = new DataOutputStream(
new ByteBufferOutputStream(channel, plainOut)
);
this.frameBuilder = new FrameBuilder(channel, plainIn);
} else {
this.ssl = true;
this.plainOut = nioParams.getByteBufferFactory().createWriteBuffer(nioContext);
this.cipherOut = nioParams.getByteBufferFactory().createEncryptedWriteBuffer(nioContext);
this.plainIn = nioParams.getByteBufferFactory().createReadBuffer(nioContext);
this.cipherIn = nioParams.getByteBufferFactory().createEncryptedReadBuffer(nioContext);
this.outputStream = new DataOutputStream(
new SslEngineByteBufferOutputStream(sslEngine, plainOut, cipherOut, channel)
);
this.frameBuilder = new SslEngineFrameBuilder(sslEngine, plainIn, cipherIn, channel);
}
} | 0 | Java | CWE-400 | Uncontrolled Resource Consumption | The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources. | https://cwe.mitre.org/data/definitions/400.html | vulnerable |
public SslEngineFrameBuilder(SSLEngine sslEngine, ByteBuffer plainIn, ByteBuffer cipherIn, ReadableByteChannel channel) {
super(channel, plainIn);
this.sslEngine = sslEngine;
this.cipherBuffer = cipherIn;
} | 0 | Java | CWE-400 | Uncontrolled Resource Consumption | The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources. | https://cwe.mitre.org/data/definitions/400.html | vulnerable |
public void buildFrameInSeveralCalls() throws IOException {
buffer = ByteBuffer.wrap(new byte[] { 1, 0, 0, 0, 0, 0, 3, 1, 2 });
builder = new FrameBuilder(channel, buffer);
Frame frame = builder.readFrame();
assertThat(frame).isNull();
buffer.clear();
buffer.put(b(3)).put(end());
buffer.flip();
frame = builder.readFrame();
assertThat(frame).isNotNull();
assertThat(frame.type).isEqualTo(1);
assertThat(frame.channel).isEqualTo(0);
assertThat(frame.getPayload()).hasSize(3);
} | 0 | Java | CWE-400 | Uncontrolled Resource Consumption | The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources. | https://cwe.mitre.org/data/definitions/400.html | vulnerable |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.