<commit_before>module Nexpose
  module NexposeAPI

    # List the scan templates currently configured on the console.
    #
    # @return [Array[String]] list of scan templates IDs.
    #
    def list_scan_templates
      templates = JSON.parse(AJAX.get(self, '/data/scan/templates'))
      templates['valueList']
    end

    alias_method :scan_templates, :list_scan_templates

    # Delete a scan template from the console.
    # Cannot be used to delete a built-in template.
    #
    # @param [String] id Unique identifier of an existing scan template.
    #
    def delete_scan_template(id)
      AJAX.delete(self, "/data/scan/templates/#{URI.encode(id)}")
    end
  end

  # Configuration object for a scan template.
  # This class is only a partial representation of some of the features
  # available for configuration.
  #
  class ScanTemplate

    # Parsed XML of a scan template
    attr_reader :xml

    # @param [String] xml XML representation of a scan template.
    def initialize(xml)
      @xml = REXML::Document.new(xml)
    end

    # @return [String] Unique identifier of the scan template.
    def id
      root = REXML::XPath.first(xml, 'ScanTemplate')
      root.attributes['id']
    end

    # @return [String] Name or title of this scan template.
    def name
      desc = REXML::XPath.first(@xml, 'ScanTemplate/templateDescription')
      desc.nil? ? nil : desc.attributes['title']
    end

    # Assign name to this scan template. Required attribute.
    # @param [String] name Title to assign.
    def name=(name)
      desc = REXML::XPath.first(@xml, 'ScanTemplate/templateDescription')
      if desc
        desc.attributes['title'] = name
      else
        root = REXML::XPath.first(xml, 'ScanTemplate')
        desc = REXML::Element.new('templateDescription')
        desc.add_attribute('title', name)
        root.add_element(desc)
      end
    end

    # @return [String] Description of this scan template.
    def description
      desc = REXML::XPath.first(@xml, 'ScanTemplate/templateDescription')
      desc.nil? ? nil : desc.text.to_s
    end

    # Assign a description to this scan template. Require attribute.
    # @param [String] description Description of the scan template.
    def description=(description)
      desc = REXML::XPath.first(@xml, 'ScanTemplate/templateDescription')
      if desc
        desc.text = description
      else
        root = REXML::XPath.first(xml, 'ScanTemplate')
        desc = REXML::Element.new('templateDescription')
        desc.add_text(description)
        root.add_element(desc)
      end
    end

    # @return [Boolean] Whether vuln scanning in enabled.
    def vuln_scanning?
      gen = REXML::XPath.first(@xml, 'ScanTemplate/General')
      gen.attributes['disableVulnScan'] == '0'
    end

    # Adjust whether to perform vuln scanning with this template.
    # @param [Boolean] enable Whether to turn on vuln scanning.
    def vuln_scanning=(enable)
      gen = REXML::XPath.first(@xml, 'ScanTemplate/General')
      gen.attributes['disableVulnScan'] == enable ? '0' : '1'
    end

    # @return [Boolean] Whether policy scanning in enabled.
    def policy_scanning?
      gen = REXML::XPath.first(@xml, 'ScanTemplate/General')
      gen.attributes['disablePolicyScan'] == '0'
    end

    # Adjust whether to perform policy scanning with this template.
    # @param [Boolean] enable Whether to turn on policy scanning.
    def policy_scanning=(enable)
      gen = REXML::XPath.first(@xml, 'ScanTemplate/General')
      gen.attributes['disablePolicyScan'] == enable ? '0' : '1'
    end

    # @return [Boolean] Whether web spidering in enabled.
    def web_spidering?
      gen = REXML::XPath.first(@xml, 'ScanTemplate/General')
      gen.attributes['disableWebSpider'] == '0'
    end

    # Adjust whether to perform web spidering with this template.
    # @param [Boolean] enable Whether to turn on web spider scanning.
    def web_spidering=(enable)
      gen = REXML::XPath.first(@xml, 'ScanTemplate/General')
      gen.attributes['disableWebSpider'] == enable ? '0' : '1'
    end

    # @return [Boolean] Whether to correlate reliable checks with regular checks.
    def correlate?
      vuln_checks = REXML::XPath.first(@xml, 'ScanTemplate/VulnerabilityChecks')
      vuln_checks.attributes['correlate'] == '1'
    end

    # Adjust whether to correlate reliable checks with regular checks.
    # @param [Boolean] enable Whether to turn on vulnerability correlation.
    def correlate=(enable)
      vuln_checks = REXML::XPath.first(@xml, 'ScanTemplate/VulnerabilityChecks')
      vuln_checks.attributes['correlate'] = enable ? '1' : '0'<commit_msg>Fixes equality typos in scanning types.<commit_after>module Nexpose
  module NexposeAPI

    # List the scan templates currently configured on the console.
    #
    # @return [Array[String]] list of scan templates IDs.
    #
    def list_scan_templates
      templates = JSON.parse(AJAX.get(self, '/data/scan/templates'))
      templates['valueList']
    end

    alias_method :scan_templates, :list_scan_templates

    # Delete a scan template from the console.
    # Cannot be used to delete a built-in template.
    #
    # @param [String] id Unique identifier of an existing scan template.
    #
    def delete_scan_template(id)
      AJAX.delete(self, "/data/scan/templates/#{URI.encode(id)}")
    end
  end

  # Configuration object for a scan template.
  # This class is only a partial representation of some of the features
  # available for configuration.
  #
  class ScanTemplate

    # Parsed XML of a scan template
    attr_reader :xml

    # @param [String] xml XML representation of a scan template.
    def initialize(xml)
      @xml = REXML::Document.new(xml)
    end

    # @return [String] Unique identifier of the scan template.
    def id
      root = REXML::XPath.first(xml, 'ScanTemplate')
      root.attributes['id']
    end

    # @return [String] Name or title of this scan template.
    def name
      desc = REXML::XPath.first(@xml, 'ScanTemplate/templateDescription')
      desc.nil? ? nil : desc.attributes['title']
    end

    # Assign name to this scan template. Required attribute.
    # @param [String] name Title to assign.
    def name=(name)
      desc = REXML::XPath.first(@xml, 'ScanTemplate/templateDescription')
      if desc
        desc.attributes['title'] = name
      else
        root = REXML::XPath.first(xml, 'ScanTemplate')
        desc = REXML::Element.new('templateDescription')
        desc.add_attribute('title', name)
        root.add_element(desc)
      end
    end

    # @return [String] Description of this scan template.
    def description
      desc = REXML::XPath.first(@xml, 'ScanTemplate/templateDescription')
      desc.nil? ? nil : desc.text.to_s
    end

    # Assign a description to this scan template. Require attribute.
    # @param [String] description Description of the scan template.
    def description=(description)
      desc = REXML::XPath.first(@xml, 'ScanTemplate/templateDescription')
      if desc
        desc.text = description
      else
        root = REXML::XPath.first(xml, 'ScanTemplate')
        desc = REXML::Element.new('templateDescription')
        desc.add_text(description)
        root.add_element(desc)
      end
    end

    # @return [Boolean] Whether vuln scanning in enabled.
    def vuln_scanning?
      gen = REXML::XPath.first(@xml, 'ScanTemplate/General')
      gen.attributes['disableVulnScan'] == '0'
    end

    # Adjust whether to perform vuln scanning with this template.
    # @param [Boolean] enable Whether to turn on vuln scanning.
    def vuln_scanning=(enable)
      gen = REXML::XPath.first(@xml, 'ScanTemplate/General')
      gen.attributes['disableVulnScan'] = enable ? '0' : '1'
    end

    # @return [Boolean] Whether policy scanning in enabled.
    def policy_scanning?
      gen = REXML::XPath.first(@xml, 'ScanTemplate/General')
      gen.attributes['disablePolicyScan'] == '0'
    end

    # Adjust whether to perform policy scanning with this template.
    # @param [Boolean] enable Whether to turn on policy scanning.
    def policy_scanning=(enable)
      gen = REXML::XPath.first(@xml, 'ScanTemplate/General')
      gen.attributes['disablePolicyScan'] = enable ? '0' : '1'
    end

    # @return [Boolean] Whether web spidering in enabled.
    def web_spidering?
      gen = REXML::XPath.first(@xml, 'ScanTemplate/General')
      gen.attributes['disableWebSpider'] == '0'
    end

    # Adjust whether to perform web spidering with this template.
    # @param [Boolean] enable Whether to turn on web spider scanning.
    def web_spidering=(enable)
      gen = REXML::XPath.first(@xml, 'ScanTemplate/General')
      gen.attributes['disableWebSpider'] = enable ? '0' : '1'
    end

    # @return [Boolean] Whether to correlate reliable checks with regular checks.
    def correlate?
      vuln_checks = REXML::XPath.first(@xml, 'ScanTemplate/VulnerabilityChecks')
      vuln_checks.attributes['correlate'] == '1'
    end

    # Adjust whether to correlate reliable checks with regular checks.
    # @param [Boolean] enable Whether to turn on vulnerability correlation.
    def correlate=(enable)
      vuln_checks = REXML::XPath.first(@xml, 'ScanTemplate/VulnerabilityChecks')
      vuln_checks.attributes['correlate'] = enable ? '1' : '0'
{'fraction_non_alphanumeric': 0.10537611331687949, 'fraction_numerical': 0.002575383624852452, 'mean_word_length': 3.096703296703297, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 40}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4200035', 'n_tokens_mistral': 2783, 'n_tokens_neox': 2685, 'n_words': 806}