import common from '../definitions/common.json';
import rawDefinition from '../definitions/malware-analysis.json';
import deepmerge from 'deepmerge';

import {Base} from './Base';

class MalwareAnalysis extends Base  {

    constructor() {
        const definition_extension = {
            "img": "malware-analysis.png",
            "prefix": "malware-analysis--",
            "active": true,
            "relationships": [
                {"type": "characterizes", "target": "malware"},
                {"type": "analysis-of", "target": "malware"},
                {"type": "static-analysis-of", "target": "malware"},
                {"type": "dynamic-analysis-of", "target": "malware"},
                {"type": "identifies", "target": "observable", "sub-target": "artifact", "x_exclusive": true, "x_embed": "sample_ref"},
                {"type": "identifies", "target": "artifact", "x_exclusive": true, "x_embed": "sample_ref"},
                {"type": "operates-on", "target": "observable", "sub-target": "software", "x_exclusive": true, "x_embed": "operating_system_refs"},
                {"type": "operates-virtually-on", "target": "observable", "sub-target": "software", "x_exclusive": true, "x_embed": "host_vm_ref"},
                {"type": "created-by", "target": "identity", "x_exclusive": true, "x_embed": "created_by_ref"},
                {"type": "observed-artifact", "target": "observable", "sub-target": "artifact", "x_embed": "analysis_sco_refs"},
                {"type": "observed-autonomous-system", "target": "observable", "sub-target": "autonomous-system", "x_embed": "analysis_sco_refs"},
                {"type": "observed-directory", "target": "observable", "sub-target": "directory", "x_embed": "analysis_sco_refs"},
                {"type": "observed-domain", "target": "observable", "sub-target": "domain-name", "x_embed": "analysis_sco_refs"},
                {"type": "observed-ipv4-addr", "target": "observable", "sub-target": "ipv4-addr", "x_embed": "analysis_sco_refs"},
                {"type": "observed-ipv6-addr", "target": "observable", "sub-target": "ipv6-addr", "x_embed": "analysis_sco_refs"},
                {"type": "observed-email-msg", "target": "observable", "sub-target": "email-message", "x_embed": "analysis_sco_refs"},
                {"type": "observed-email-addr", "target": "observable", "sub-target": "email-addr", "x_embed": "analysis_sco_refs"},
                {"type": "observed-file", "target": "observable", "sub-target": "file", "x_embed": "analysis_sco_refs"},
                {"type": "observed-mac-addr", "target": "observable", "sub-target": "mac-addr", "x_embed": "analysis_sco_refs"},
                {"type": "observed-mutex", "target": "observable", "sub-target": "mutex", "x_embed": "analysis_sco_refs"},
                {"type": "observed-network-traffic", "target": "observable", "sub-target": "network-traffic", "x_embed": "analysis_sco_refs"},
                {"type": "observed-process", "target": "observable", "sub-target": "process", "x_embed": "analysis_sco_refs"},
                {"type": "observed-software", "target": "observable", "sub-target": "software", "x_embed": "analysis_sco_refs"},
                {"type": "observed-url", "target": "observable", "sub-target": "url", "x_embed": "analysis_sco_refs"},
                {"type": "observed-user-account", "target": "observable", "sub-target": "user-account", "x_embed": "analysis_sco_refs"},
                {"type": "observed-win-reg-key", "target": "observable", "sub-target": "windows-registry-key", "x_embed": "analysis_sco_refs"},
                {"type": "observed-x509-cert", "target": "observable", "sub-target": "x509-certificate", "x_embed": "analysis_sco_refs"},
                {"type": "observed-artifact", "target": "artifact", "x_embed": "analysis_sco_refs"},
                {"type": "observed-autonomous-system", "target": "autonomous-system", "x_embed": "analysis_sco_refs"},
                {"type": "observed-directory", "target": "directory", "x_embed": "analysis_sco_refs"},
                {"type": "observed-domain", "target": "domain-name", "x_embed": "analysis_sco_refs"},
                {"type": "observed-ipv4-addr", "target": "ipv4-addr", "x_embed": "analysis_sco_refs"},
                {"type": "observed-ipv6-addr", "target": "ipv6-addr", "x_embed": "analysis_sco_refs"},
                {"type": "observed-email-msg", "target": "email-message", "x_embed": "analysis_sco_refs"},
                {"type": "observed-email-addr", "target": "email-addr", "x_embed": "analysis_sco_refs"},
                {"type": "observed-file", "target": "file", "x_embed": "analysis_sco_refs"},
                {"type": "observed-mac-addr", "target": "mac-addr", "x_embed": "analysis_sco_refs"},
                {"type": "observed-mutex", "target": "mutex", "x_embed": "analysis_sco_refs"},
                {"type": "observed-network-traffic", "target": "network-traffic", "x_embed": "analysis_sco_refs"},
                {"type": "observed-process", "target": "process", "x_embed": "analysis_sco_refs"},
                {"type": "observed-software", "target": "software", "x_embed": "analysis_sco_refs"},
                {"type": "observed-url", "target": "url", "x_embed": "analysis_sco_refs"},
                {"type": "observed-user-account", "target": "user-account", "x_embed": "analysis_sco_refs"},
                {"type": "observed-win-reg-key", "target": "windows-registry-key", "x_embed": "analysis_sco_refs"},
                {"type": "observed-x509-cert", "target": "x509-certificate", "x_embed": "analysis_sco_refs"}
            ]
        }

        let def = deepmerge(definition_extension, rawDefinition);

        super(common, def);

        this.properties["modules"].control = "csv";
        this.properties["host_vm_ref"].control = "hidden";
        this.properties["operating_system_ref"].control = "hidden";
        this.properties["installed_software_refs"].control = "hidden";
        this.properties["sample_ref"].control = "hidden";
        this.properties["sample_ref"].type = "string";
        this.properties["sample_ref"].value = "";
        this.properties["operating_system_ref"].type = "string";
        this.properties["operating_system_ref"].value = "";
        this.properties["host_vm_ref"].value = "";
        this.properties["analysis_sco_refs"].control = "hidden";
    }
}

const singleton = new MalwareAnalysis();

export default singleton
