Exemple #1
0
 def __init__(self, hosts, server=None):
     """
     <method maturity="stable">
       <summary>
         Constructor to initialize an instance of the DNSMatcher class.
       </summary>
       <description>
         <para>
           This constructor initializes an instance of the DNSMatcher class.
         </para>
       </description>
       <metainfo>
         <arguments>
           <argument maturity="stable">
             <name>hosts</name>
             <type>
               <list>
                 <string/>
               </list>
             </type>
             <description>Hostnames to resolve.</description>
           </argument>
           <argument maturity="stable">
             <name>server</name>
             <type>
               <string/>
             </type>
             <default>None</default>
             <description>IP address of the DNS server to query. Defaults to the servers set in
             the <filename>resolv.conf</filename> file.</description>
           </argument>
         </arguments>
       </metainfo>
     </method>
     """
     self.cache = ResolverCache(DNSResolver(server=server))
     if isinstance(hosts, str):
         self.cache.addHost(hosts)
     elif isinstance(hosts, collections.Iterable):
         for host in hosts:
             self.cache.addHost(host)
     else:
         raise ValueError('hosts has type %s, must be str or iterable')
Exemple #2
0
 def __init__(self, hosts, server=None):
     """
     <method maturity="stable">
       <summary>
         Constructor to initialize an instance of the DNSMatcher class.
       </summary>
       <description>
         <para>
           This constructor initializes an instance of the DNSMatcher class.
         </para>
       </description>
       <metainfo>
         <arguments>
           <argument maturity="stable">
             <name>hosts</name>
             <type>
               <list>
                 <string/>
               </list>
             </type>
             <description>Hostnames to resolve.</description>
           </argument>
           <argument maturity="stable">
             <name>server</name>
             <type>
               <string/>
             </type>
             <default>None</default>
             <description>IP address of the DNS server to query. Defaults to the servers set in
             the <filename>resolv.conf</filename> file.</description>
           </argument>
         </arguments>
       </metainfo>
     </method>
     """
     self.cache = ResolverCache(DNSResolver())
Exemple #3
0
 def __init__(self, hosts, server=None):
     """
     <method maturity="stable">
       <summary>
         Constructor to initialize an instance of the DNSMatcher class.
       </summary>
       <description>
         <para>
           This constructor initializes an instance of the DNSMatcher class.
         </para>
       </description>
       <metainfo>
         <arguments>
           <argument maturity="stable">
             <name>hosts</name>
             <type>
               <list>
                 <string/>
               </list>
             </type>
             <description>Hostnames to resolve.</description>
           </argument>
           <argument maturity="stable">
             <name>server</name>
             <type>
               <string/>
             </type>
             <default>None</default>
             <description>IP address of the DNS server to query. Defaults to the servers set in
             the <filename>resolv.conf</filename> file.</description>
           </argument>
         </arguments>
       </metainfo>
     </method>
     """
     self.cache = ResolverCache(DNSResolver())
     if isinstance(hosts, str):
         self.cache.addHost(hosts)
     elif isinstance(hosts, collections.Iterable):
         for host in hosts:
             self.cache.addHost(host)
     else:
         raise ValueError('hosts has type %s, must be str or iterable')
Exemple #4
0
 def __init__(self, hosts, server=None):
     """
     <method maturity="stable">
       <summary>
         Constructor to initialize an instance of the DNSMatcher class.
       </summary>
       <description>
         <para>
           This constructor initializes an instance of the DNSMatcher class.
         </para>
       </description>
       <metainfo>
         <arguments>
           <argument maturity="stable">
             <name>hosts</name>
             <type>
               <list>
                 <string/>
               </list>
             </type>
             <description>Hostnames to resolve.</description>
           </argument>
           <argument maturity="stable">
             <name>server</name>
             <type>
               <string/>
             </type>
             <default>None</default>
             <description>IP address of the DNS server to query. Defaults to the servers set in
             the <filename>resolv.conf</filename> file.</description>
           </argument>
         </arguments>
       </metainfo>
     </method>
     """
     self.cache = ResolverCache(DNSResolver())
Exemple #5
0
class DNSMatcher(AbstractMatcher):
    """
    <class maturity="stable">
      <summary>
        DNS matcher
      </summary>
      <description>
        <para>
          DNSMatcher retrieves the IP addresses of domain names. This can be used in domain name based
          policy decisions, for example to allow encrypted connections only to trusted e-banking sites.
        </para>
        <para>
          DNSMatcher operates as follows: it resolves the IP addresses stored in the list of domain names using the specified Domain Name Server,
          and compares the results to the IP address of the connection (i.e., the IP address of the server or the client).
            The matcher returns a true value if the IP addresses resolved from the list of domain names include the
            IP address of the connection.
        </para>
        <example>
        <title>DNSMatcher example</title>
        <para>
        The following DNSMatcher class uses the <parameter>dns.example.com</parameter> name server to
        resolve the <parameter>example2.com</parameter> and <parameter>example3.com</parameter> domain names.
        </para>
        <synopsis>MatcherPolicy(name="ExampleDomainMatcher", matcher=DNSMatcher(server="dns.example.com", hosts=("example2.com", "example3.com")))</synopsis>
        </example>
      </description>
      <metainfo>
        <attributes/>
      </metainfo>
    </class>
    """

    def __init__(self, hosts, server=None):
        """
        <method maturity="stable">
          <summary>
            Constructor to initialize an instance of the DNSMatcher class.
          </summary>
          <description>
            <para>
              This constructor initializes an instance of the DNSMatcher class.
            </para>
          </description>
          <metainfo>
            <arguments>
              <argument maturity="stable">
                <name>hosts</name>
                <type>
                  <list>
                    <string/>
                  </list>
                </type>
                <description>Hostnames to resolve.</description>
              </argument>
              <argument maturity="stable">
                <name>server</name>
                <type>
                  <string/>
                </type>
                <default>None</default>
                <description>IP address of the DNS server to query. Defaults to the servers set in
                the <filename>resolv.conf</filename> file.</description>
              </argument>
            </arguments>
          </metainfo>
        </method>
        """
        self.cache = ResolverCache(DNSResolver(server=server))
        if isinstance(hosts, str):
            self.cache.addHost(hosts)
        elif isinstance(hosts, collections.Iterable):
            for host in hosts:
                self.cache.addHost(host)
        else:
            raise ValueError('hosts has type %s, must be str or iterable')

    def checkMatch(self, str):
        """<method internal="yes"/>
        """
        res = self.cache.lookupAddress(str)

        if res is not None:
            return TRUE
        else:
            return FALSE
Exemple #6
0
class DNSMatcher(AbstractMatcher):
    """
    <class maturity="stable">
      <summary>
        DNS matcher
      </summary>
      <description>
        <para>
          DNSMatcher retrieves the IP addresses of domain names. This can be used in domain name based
          policy decisions, for example to allow encrypted connections only to trusted e-banking sites.
        </para>
        <para>
          DNSMatcher operates as follows: it resolves the IP addresses stored in the list of domain names using the specified Domain Name Server,
          and compares the results to the IP address of the connection (i.e., the IP address of the server or the client).
            The matcher returns a true value if the IP addresses resolved from the list of domain names include the
            IP address of the connection.
        </para>
        <example>
        <title>DNSMatcher example</title>
        <para>
        The following DNSMatcher class uses the <parameter>dns.example.com</parameter> name server to
        resolve the <parameter>example2.com</parameter> and <parameter>example3.com</parameter> domain names.
        </para>
        <synopsis>MatcherPolicy(name="ExampleDomainMatcher", matcher=DNSMatcher(server="dns.example.com", hosts=("example2.com", "example3.com")))</synopsis>
        </example>
      </description>
      <metainfo>
        <attributes/>
      </metainfo>
    </class>
    """

    def __init__(self, hosts, server=None):
        """
        <method maturity="stable">
          <summary>
            Constructor to initialize an instance of the DNSMatcher class.
          </summary>
          <description>
            <para>
              This constructor initializes an instance of the DNSMatcher class.
            </para>
          </description>
          <metainfo>
            <arguments>
              <argument maturity="stable">
                <name>hosts</name>
                <type>
                  <list>
                    <string/>
                  </list>
                </type>
                <description>Hostnames to resolve.</description>
              </argument>
              <argument maturity="stable">
                <name>server</name>
                <type>
                  <string/>
                </type>
                <default>None</default>
                <description>IP address of the DNS server to query. Defaults to the servers set in
                the <filename>resolv.conf</filename> file.</description>
              </argument>
            </arguments>
          </metainfo>
        </method>
        """
        self.cache = ResolverCache(DNSResolver())

    def checkMatch(self, str):
        """<method internal="yes"/>
        """
        res = self.cache.lookupAddress(str)

        if res is not None:
            return TRUE
        else:
            return FALSE