Ticket #15 (closed improvement: fixed)

Opened 2 years ago

Last modified 1 year ago

Improve Config package, to support lists of arbitrary data

Reported by: kindlund Assigned to: kindlund
Priority: normal Milestone: 0.9
Component: HoneyClient::Util::Config Version: 0.96
Severity: none Keywords: xml, config, util, file, registry
Cc:

Description

Currently, all data defined in etc/honeyclient.xml must be a scalar type (i.e., string, integer).

Task: Update the Config package to support list-based configuration data, allowing enumerated lists to be manipulated as arrays.

For example, if etc/honeyclient.xml contained the following data:

<HoneyClient>
    <Agent>
        <Integrity>
            <exclude_file>c:\path\to\file1.exe</exclude_file>
            <exclude_file>c:\path\to\file2.exe</exclude_file>
            <exclude_file>c:\path\to\file3.exe</exclude_file>
            <exclude_registry>HKCU\path\to\key1</exclude_registry>
            <exclude_registry>HKCU\path\to\key2</exclude_registry>
            <exclude_registry>HKCU\path\to\key3</exclude_registry>
        </Integrity>
    </Agent>
</HoneyClient>

Then, the following code should work:

use HoneyClient::Util::Config qw(getVar);

my @exclude_files = getVar(name      => "exclude_file",
                           namespace => "Honeyclient::Agent::Integrity");
my @exclude_registry = getVar(name      => "exclude_registry",
                              namespace => "Honeyclient::Agent::Integrity");

Attachments

Change History

04/25/07 17:16:00 changed by kindlund

  • status changed from new to closed.
  • resolution set to fixed.
  • milestone changed from 1.0 to 0.9.

Fixed in the trunk branch. r261

For target elements that contain multiple child elements, getVar() will return a hashtable reference instead of an array. This is due to the fact that the child elements may be uniquely named.

If the variable found is an element that contains child elements, then a corresponding hashtable will be returned. For example, if we perform a getVar(name => "foo") on the following XML:

  <HoneyClient>
      <foo>
          <bar>123</bar>
          <bar>456</bar>
          <yok>789</yok>
          <yok>xxx</yok>
      </foo>
  </HoneyClient>

Then the following $hashref will be returned:

  $hashref = {
      'bar' => [ '123', '456' ],
      'yok' => [ '789', 'xxx' ],
  }

08/29/07 14:12:37 changed by kindlund

  • version changed from none to 0.96.

Add/Change #15 (Improve Config package, to support lists of arbitrary data)




Change Properties
Action