Built-In Namespace String
Method Attributes | Method Name and Description |
---|---|
convertIP(radix)
Converts an IP address in a number of input forms into the standard dotted-quad notation used by Sentinel.
|
|
getHashValue(hashtype)
Creates a hash value of a string.
|
|
insert(start, num, ins)
Inserts a string at a specified character position, replacing that character
|
|
This method converts the string from Base64 encoding to a regular string.
|
|
Converts an LDAP-formatted string into an object with separate attributes to contain the
CN and the rest of the directory structure.
|
|
parseNVP(pairSep, NVSep, quote)
The parseNVP() function converts a string in name-value pair format into
a hash where each value can be retrieved by its name.
|
|
Converts a standard path into a normalized form.
|
|
Parse a Syslog string.
|
|
safesplit(delim, quote)
Splits a string into substrings based on a delimiter character.
|
|
trim()
Removes whitespace from the beginning and end of the string.
|
Method Detail
{String}
convertIP(radix)
Converts an IP address in a number of input forms into the standard dotted-quad notation used by Sentinel.
Defined in: utils.js.
Defined in: utils.js.
- Parameters:
- {Number} radix
- The radix of the input; 16 for hex, 8 for octal, etc. Default is 10 for decimal.
- Returns:
- {String} The converted IP address in normalized, dotted-quad form (network order)
{String}
getHashValue(hashtype)
Creates a hash value of a string. Message digests are secure one-way hash functions
that take arbitrary-sized data and output a fixed-length hash value.
Defined in: utils.js.
Defined in: utils.js.
- Parameters:
- {String} hashtype
- One of 'MD2','MD5','SHA','SHA-1','SHA-2','SHA-256','SHA-384','SHA-512' specifying the hash algorithm
- Returns:
- {String} checksum The computed hash value of a string or 'undefined' if it fails due to any reason.
{String}
insert(start, num, ins)
Inserts a string at a specified character position, replacing that character
Defined in: utils.js.
Defined in: utils.js.
var str = "this is a string"; var newstr = str.insert(8, 1, "my");
- Parameters:
- {Number} start
- Character position in the string at which the inserted string should be placed.
- {Number} num
- Number of characters to consume while inserting string
- {String} ins
- String to insert into this
- Returns:
- {String}
parseBase64()
This method converts the string from Base64 encoding to a regular string.
Note that in general you should only attempt to decode strings; decoding binary data
may cause issues.
Defined in: utils.js.
Defined in: utils.js.
var string="SGVsbG8sIHdvcmxk"; var outstring=string.parseBase64();
{Hash}
parseLDAP()
Converts an LDAP-formatted string into an object with separate attributes to contain the
CN and the rest of the directory structure.
This method will take a normal LDAP string (CN=user1.OU=users.OU=engineering.O=novell) and
convert it into an object with separate attributes for the base name and domain (in Sentinel
parlance. This object has two fields:
Defined in: utils.js.
- basename: The base common name of the object (ex. "user1")
- domain: the rest of the path for the object, in slash notation (ex. "\novell\engineering\users")
Example:
var ldapuser = "CN=user1.OU=users.OU=engineering.O=novell"; var ldapobj = ldapuser.parseLDAP(); // In Rec2Evt.map, modify the lines to say: InitUserName,ldapobj.basename InitUserDomain,ldapobj.domain
Defined in: utils.js.
- Returns:
- {Hash} Two-attribute object with basename and domain from LDAP string
{Hash}
parseNVP(pairSep, NVSep, quote)
The parseNVP() function converts a string in name-value pair format into
a hash where each value can be retrieved by its name. For example, the
string "name=value" would be converted to obj["name"] = value.
Defined in: utils.js.
Note that in some cases you may need to pre-process your string to avoid confusion. Quoting in particular can be thorny, and you'll need to make sure there are no unquoted characters that look like separators but really aren't.
Example:
var input='a=1 b=2 c=hello d="one token"' input.parseNVP(" ","=",'"')
Defined in: utils.js.
- Parameters:
- {char} pairSep
- Character(s) that separate one entry pair from another
- {char} NVSep
- Character(s) that separate names from values in a single pair
- {char} quote
- Quote character used for values; if '[', '(', or '{' are used this function will look for the natural closing bracket to end a quoted section.
- Returns:
- {Hash} Map of names (attributes) to values
{Object}
parsePath()
Converts a standard path into a normalized form.
This method will take standard Unix and Windows paths and transform them into a normalized form.
It returns this normalized form as an object containing two elements:
this.object : the terminal element in the path, e.g. the name of the actual object
this.context : the slash-separated path which defines the namespace in which that object is contained.
Often these elements will ultimately be assigned to TargetDataName and TargetDataContainer in the output event.
Defined in: utils.js.
Defined in: utils.js.
- Returns:
- {Object} Two-element object that contains an 'object' attribute and a 'context' attribute.
{Hash}
parseSyslog()
Parse a Syslog string.
Note that this method assumes strict RFC3164 compliance, namely:
Mon DD HH:MM:SS (host) (message)
Also: Syslog messages lack a year, so this method assumes that events were generated
in the current year *except* if the month is December and the current month is January.
Defined in: utils.js.
Defined in: utils.js.
- Returns:
- {Hash} Three-attribute object with date, host, and message from Syslog string
{String[]}
safesplit(delim, quote)
Splits a string into substrings based on a delimiter character.
The safesplit() method works like the split() method, except that it protects
quoted text sections from being split at the delimiter. It will strip quotes from
any token that ends up being an entire output token (and will de-escape embedded
quotes); otherwise it will leave quotes and escapes intact.
Defined in: utils.js.
Note: does not support the "howmany" argument from split().
Example:
var input1='token1,token2,"token3,including this",token4,token5\\"embedded quote' var output1=input1.safesplit(); var input2="this (string) used (parentheses) as quote (chars) \(but not this one\)" var output2=input2.safesplit(" ","(");
Defined in: utils.js.
- Parameters:
- {char} delim
- The delimiter (n char substring) to split the string on - does NOT support empty string
- {char} quote
- The quote character; if '[', '(', or '{' are used this function will look for the natural closing bracket to end a quoted section.
- Returns:
- {String[]} An output array of token strings
{String}
trim()
Removes whitespace from the beginning and end of the string.
Defined in: utils.js.
Defined in: utils.js.
- Returns:
- {String} The trimmed string