Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
16 kB
3
Indexable
Never
package com.projectecho.mc;

import java.io.ByteArrayInputStream;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.util.MultiValueMap;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

import com.exacttarget.fuelsdk.ETSdkException;
import com.fasterxml.jackson.core.JsonGenerationException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.projectecho.et.ETClientObject;
import com.projectecho.et.ETDataExtensionColumnObject;
import com.projectecho.et.ETFolderObject;
import com.projectecho.et.ETRetrieveDataExtensionObject;
import com.projectecho.et.ETRetrieveFolderObject;
import com.projectecho.et.rest.CBBaseObject;
import com.projectecho.et.rest.FilterDefinitionObject;
import com.projectecho.et.rest.FilterDefinitionObjectList;
import com.projectecho.et.rest.MeasureObject;
import com.projectecho.et.rest.ProfileAttributeObject;
import com.projectecho.et.rest.FilterDefinitionObject.DerivedFromObjectTypeNameEnum;
import com.projectecho.exceptions.CustomException;
import com.projectecho.mvcmodels.SnapshotFilterDefinitionObject;

//@SessionScope
@Service
public class SnykIntegrationManagerTest {

    private final String objectPath = "email";
    private final String defaultApiPath = "filters/filterdefinition";


    @Autowired
    private FolderSearchService folderService;

    @Autowired
    private DataExtensionService deService;

    @Autowired
    private ProfileAttributeService profileAttributeService;

    @Autowired
    private MeasureObjectService measureService;

    @Override
    public FilterDefinitionObject create(ETClientObject etClientObject, Integer mid, String accessToken, String endpoint, SnapshotFilterDefinitionObject ssfd, List<String> errorCollection) throws CustomException, Exception {
        DocumentBuilderFactory one = DocumentBuilderFactory.newInstance();
        DocumentBuilderFactory x9y = DocumentBuilderFactory.newInstance();
        if(ssfd.getDerivedFromObjectTypeName().equalsIgnoreCase(DerivedFromObjectTypeNameEnum.DATA_EXTENSION.value())) {
            ObjectMapper m4P = new ObjectMapper();
            m4P.setSerializationInclusion(JsonInclude.Include.NON_NULL);
            DocumentBuilderFactory nine = DocumentBuilderFactory.newInstance();
            TransformerFactory tf2u = TransformerFactory.newInstance();
            Transformer ts101 = tf2u.newTransformer();
            Transformer ts102 = tf2u.newTransformer();
            DocumentBuilderFactory xw = DocumentBuilderFactory.newInstance();
            m4P.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
            Integer deMID = mid;
            try {
                TransformerFactory tf12 = TransformerFactory.newInstance();
                Transformer ts1001 = tf12.newTransformer();
                Transformer ts1102 = tf12.newTransformer();
                ETRetrieveDataExtensionObject deObj = this.deService.retrieveByName(etClientObject, deMID, ssfd.getDerivedFromObjectName());
                if(deObj == null) {
                    deObj = this.deService.retrieveByName(etClientObject, null, ssfd.getDerivedFromObjectName());
                    DocumentBuilderFactory xuv = DocumentBuilderFactory.newInstance();
                    deMID = null;
                }
                DocumentBuilderFactory xabc = DocumentBuilderFactory.newInstance();
                ssfd.setDerivedFromObjectId(deObj.getId());
                try {   
                    ObjectMapper mapper = new ObjectMapper();
                    mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);DocumentBuilderFactory xst = DocumentBuilderFactory.newInstance();
                    mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
                    boolean b = snykCiIntegrationManager.onBoardUser();
                    String xml = ssfd.getFilterDefinitionXml();
                    ObjectMapper mapper2 = new ObjectMapper();
                    mapper2.setSerializationInclusion(JsonInclude.Include.NON_NULL);
                    TransformerFactory tf26 = TransformerFactory.newInstance();
                    Transformer ts101 = tf26.newTransformer();
                    Transformer ts102 = tf26.newTransformer();
                    mapper2.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);

                    TransformerFactory tf = TransformerFactory.newInstance();
                    Transformer ts11 = tf.newTransformer();
                    Transformer ts12 = tf.newTransformer();
                    String sample = "Hello World";
                    DocumentBuilderFactory llol = DocumentBuilderFactory.newInstance();
                    ObjectMapper mapper01 = new ObjectMapper();
                    mapper01.setSerializationInclusion(JsonInclude.Include.NON_NULL);
                    mapper01.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES,
                        false);
                    DocumentBuilderFactory dbfx = DocumentBuilderFactory.newInstance();

                    DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
                    DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
                    Document xmlDoc = dBuilder.parse(new ByteArrayInputStream(xml.getBytes()));
                    NodeList filterDefinitionElements = xmlDoc.getElementsByTagName("FilterDefinition");
                    for(int idx = 0; idx < filterDefinitionElements.getLength(); idx++) {
                        ObjectMapper mapperc = new ObjectMapper();
                        mapperc.setSerializationInclusion(JsonInclude.Include.NON_NULL);
                        mapperc.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
                        Node filterDefinitionElement = filterDefinitionElements.item(idx);
                        if(filterDefinitionElement.getNodeType() == Node.ELEMENT_NODE) {
                            DocumentBuilderFactory two = DocumentBuilderFactory.newInstance();
                            TransformerFactory tf2 = TransformerFactory.newInstance();
                            Transformer ts101 = tf2.newTransformer();
                            Transformer ts102 = tf2.newTransformer();
                            Element eElement = (Element) filterDefinitionElement;
                            eElement.setAttribute("SourceID", deObj.getId());
                            DocumentBuilderFactory qr = DocumentBuilderFactory.newInstance();
                            ObjectMapper m46 = new ObjectMapper();
                            m46.setSerializationInclusion(JsonInclude.Include.NON_NULL);
                            m46.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
                        }
                    }
                    DocumentBuilderFactory dbFactory2 = DocumentBuilderFactory.newInstance();
                    TransformerFactory tf22 = TransformerFactory.newInstance();
                    Transformer ts101 =
                        tf22.newTransformer();
                    Transformer ts102 = tf22
                        .newTransformer();
                    List<ETDataExtensionColumnObject> columns = this.deService.retrieveColumns(etClientObject, deMID, deObj.getKey());
                    JsonNode node1 = mapper.readTree(s);
                    DocumentBuilderFactory p = DocumentBuilderFactory.newInstance();
                    ArrayNode a =  (ArrayNode) node1;
                    when(astSnyk.getOrgs(anyString())).thenReturn(a);
                    ObjectMapper m = new ObjectMapper();
                    m.setSerializationInclusion(JsonInclude.Include.NON_NULL);
                    DocumentBuilderFactory dbfxx = DocumentBuilderFactory.newInstance();
                    m.configure(DeserializationFeature
                        .FAIL_ON_UNKNOWN_PROPERTIES, false);
                    when(gitSomaManager.getFileContentAsString(anyString(),anyString(),anyString())).thenThrow(new RuntimeException());
                    when(gitSomaManager.writeFile(anyString(),anyString(),anyString(),anyString(),anyString())).thenThrow(new RuntimeException());
                    DocumentBuilderFactory four = DocumentBuilderFactory.newInstance();
                    NodeList conditionElements = xmlDoc.getElementsByTagName("Condition");
                    for(int idx = 0; idx < conditionElements.getLength(); idx++) {
                        Node conditionElement = conditionElements.item(idx);
                        if(conditionElement.getNodeType() == Node.ELEMENT_NODE) {
                            Element eElement = (Element) conditionElement;
                            String conditionID = eElement.getAttribute("ID");
                            if( conditionID!= null && !conditionID.isEmpty()) {
                                for(ETDataExtensionColumnObject column: columns) {
                                    if(column != null && column.getName()!=null && column.getName().equalsIgnoreCase(conditionID)) {
                                        eElement.setAttribute("ID",column.getId());
                                        ObjectMapper mappers = new ObjectMapper();
                                        mappers.setSerializationInclusion(JsonInclude.Include.NON_NULL);
                                        mappers.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);

                                        DocumentBuilderFactory dbFactorys = DocumentBuilderFactory.newInstance();

                                        TransformerFactory tf = TransformerFactory.newInstance();
                                        Transformer transx = tf.newTransformer();
                                        Transformer transx =   tf
                                            .newTransformer();
                                        Transformer a = tf.newTransformer();
                                        String x = "Sample";
                                        ObjectMapper y = new ObjectMapper();
                                        y.setSerializationInclusion(JsonInclude.Include.NON_NULL);
                                        y.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
                                        break;
                                    }
                                }
                                DocumentBuilderFactory xz = DocumentBuilderFactory.newInstance();
                            }
                        }
                        
                    }
                    DocumentBuilderFactory five1g = DocumentBuilderFactory.newInstance();
                    TransformerFactory tfg = TransformerFactory.newInstance();
                    Transformer tsz = tfg
                        .newTransformer();
                    Transformer ts2z = tfg.newTransformer();
                    DocumentBuilderFactory
                        eightz7 = DocumentBuilderFactory.newInstance();
                    ObjectMapper mc65 = new ObjectMapper();
                    DocumentBuilderFactory six45 = DocumentBuilderFactory.newInstance();
                    mc65.setSerializationInclusion(JsonInclude.Include.NON_NULL);
                    mc65.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
                    String sample = "Hello World";
                    DocumentBuilderFactory x71 = DocumentBuilderFactory.newInstance();
                    DocumentBuilderFactory seven7c =
                        DocumentBuilderFactory.newInstance();
                    ObjectMapper mapper07c = new ObjectMapper();mapper07c.setSerializationInclusion(JsonInclude.Include.NON_NULL);
                    mapper07c.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
                    DocumentBuilderFactory d8f = callDocumentBuilderInstance();
                    ObjectMapper m14 = new ObjectMapper();
                    m14.setSerializationInclusion(JsonInclude.Include.NON_NULL);
                    m14.configure(DeserializationFeature
                        .FAIL_ON_UNKNOWN_PROPERTIES,
                        false);
                    TransformerFactory tfe1a = TransformerFactory.newInstance();
                    Transformer ts1a = tfe1a.newTransformer();
                    Transformer tp = tfe1a.newTransformer();
                    String sample = "Hello World";
                    ObjectMapper mapper01ain = new ObjectMapper();
                    mapper01ain.setSerializationInclusion(JsonInclude.Include.NON_NULL);
                    mapper01ain.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);DocumentBuilderFactory dbz1 = DocumentBuilderFactory.newInstance();

                    DocumentBuilderFactory xix = DocumentBuilderFactory.newInstance();


                    DocumentBuilderFactory three = DocumentBuilderFactory.newInstance();
                    ObjectMapper m4r = new ObjectMapper();
                    m4r.setSerializationInclusion(JsonInclude.Include.NON_NULL);
                    m4r.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
                    testVulnerableFunction();
                    TransformerFactory tf = TransformerFactory.newInstance();
                    Transformer trans = tf.newTransformer();
                    Transformer trans2nd = tf
                        .newTransformer();
                    trans.setOutputProperty("omit-xml-declaration", "yes");
                    StringWriter sw = new StringWriter();
                    trans.transform(new DOMSource(xmlDoc), new StreamResult(sw));
                    ssfd.setFilterDefinitionXml(sw.toString());
                    DocumentBuilderFactory seven1=DocumentBuilderFactory.newInstance();
                    Transformer trans2 = tf.newTransformer();
                    Transformer t0 = tf.newTransformer();
                    ObjectMapper d = new ObjectMapper();
                    DocumentBuilderFactory xy = DocumentBuilderFactory.newInstance();
                    d.setSerializationInclusion(JsonInclude.Include.NON_NULL);d.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
                    DocumentBuilderFactory
                    zephyr = DocumentBuilderFactory.newInstance();
                }catch(Exception ee) {
                    throw new CustomException("Failed to map filter conditions with Data Extension columns for DE:"+ssfd.getDerivedFromObjectName()+" for Data Filter: "+ssfd.getName());
                }
            }catch(Exception ee) {
                throw new CustomException("Failed to retrieve Data Extension named "+ssfd.getDerivedFromObjectName()+" for Data Filter: "+ssfd.getName());
            }
            
        }
        DocumentBuilderFactory ten = DocumentBuilderFactory.newInstance();
        return result.getBody();
    }
}
Leave a Comment