<?xml version="1.0" encoding="UTF-8"?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

  <xs:simpleType name="stringtype">
    <xs:restriction base="xs:string">
      <xs:minLength value="1" />
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="uritype">
    <xs:restriction base="xs:anyURI">
      <xs:minLength value="1" />
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="typetype">
    <xs:restriction base="stringtype">
      <xs:enumeration value="SQLI"/>
      <xs:enumeration value="MULTI"/>
      <xs:enumeration value="REDIRECT"/>
      <xs:enumeration value="RCE"/>
      <xs:enumeration value="RFI"/>
      <xs:enumeration value="LFI"/>
      <xs:enumeration value="UPLOAD"/>
      <xs:enumeration value="UNKNOWN"/>
      <xs:enumeration value="XSS"/>
      <xs:enumeration value="CSRF"/>
      <xs:enumeration value="AUTHBYPASS"/>
      <xs:enumeration value="FPD"/>
      <xs:enumeration value="XXE"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:complexType name="itemtype">
    <xs:sequence>
      <xs:element name="vulnerability" type="vulntype" maxOccurs="unbounded" minOccurs="1" />
    </xs:sequence>
    <xs:attribute type="stringtype" name="name" use="required"/>
  </xs:complexType>

  <xs:complexType name="wordpresstype">
    <xs:sequence>
      <xs:element name="vulnerability" type="vulntype" maxOccurs="unbounded" minOccurs="1" />
    </xs:sequence>
    <xs:attribute type="stringtype" name="version" use="required"/>
  </xs:complexType>

  <xs:complexType name="vulntype">
    <xs:sequence minOccurs="1" maxOccurs="1">
      <xs:element name="title" type="stringtype"/>
      <xs:element name="reference" type="uritype" maxOccurs="unbounded" minOccurs="1"/>
      <xs:element name="metasploit" type="stringtype" maxOccurs="unbounded" minOccurs="0"/>
      <xs:element name="type" type="typetype"/>
      <xs:element name="fixed_in" type="stringtype" minOccurs="0" maxOccurs="1"/>
    </xs:sequence>
  </xs:complexType>

  <xs:element name="vulnerabilities">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="plugin" type="itemtype" maxOccurs="unbounded" minOccurs="0"/>
        <xs:element name="theme" type="itemtype" maxOccurs="unbounded" minOccurs="0"/>
        <xs:element name="wordpress" type="wordpresstype" maxOccurs="unbounded" minOccurs="0"/>
      </xs:sequence>
    </xs:complexType>
    <xs:unique name="uniquePlugin">
      <xs:selector xpath="plugin"/>
      <xs:field xpath="@name"/>
    </xs:unique>
    <xs:unique name="uniqueTheme">
      <xs:selector xpath="theme"/>
      <xs:field xpath="@name"/>
    </xs:unique>
    <xs:unique name="uniqueWordpress">
      <xs:selector xpath="wordpress"/>
      <xs:field xpath="@version"/>
    </xs:unique>
  </xs:element>

</xs:schema>
