EPO Web API Scripting Guide En-Us
EPO Web API Scripting Guide En-Us
COPYRIGHT
TRADEMARK ATTRIBUTIONS
AVERT, EPO, EPOLICY ORCHESTRATOR, FOUNDSTONE, GROUPSHIELD, INTRUSHIELD, LINUXSHIELD, MAX (MCAFEE SECURITYALLIANCE EXCHANGE),
MCAFEE, NETSHIELD, PORTALSHIELD, PREVENTSYS, SECURITYALLIANCE, SITEADVISOR, TOTAL PROTECTION, VIRUSSCAN, WEBSHIELD are registered
trademarks or trademarks of McAfee, Inc. and/or its affiliates in the US and/or other countries. McAfee Red in connection with security is distinctive of
McAfee brand products. All other registered and unregistered trademarks herein are the sole property of their respective owners.
LICENSE INFORMATION
License Agreement
NOTICE TO ALL USERS: CAREFULLY READ THE APPROPRIATE LEGAL AGREEMENT CORRESPONDING TO THE LICENSE YOU PURCHASED, WHICH SETS
FORTH THE GENERAL TERMS AND CONDITIONS FOR THE USE OF THE LICENSED SOFTWARE. IF YOU DO NOT KNOW WHICH TYPE OF LICENSE YOU
HAVE ACQUIRED, PLEASE CONSULT THE SALES AND OTHER RELATED LICENSE GRANT OR PURCHASE ORDER DOCUMENTS THAT ACCOMPANY YOUR
SOFTWARE PACKAGING OR THAT YOU HAVE RECEIVED SEPARATELY AS PART OF THE PURCHASE (AS A BOOKLET, A FILE ON THE PRODUCT CD, OR A
FILE AVAILABLE ON THE WEBSITE FROM WHICH YOU DOWNLOADED THE SOFTWARE PACKAGE). IF YOU DO NOT AGREE TO ALL OF THE TERMS SET
FORTH IN THE AGREEMENT, DO NOT INSTALL THE SOFTWARE. IF APPLICABLE, YOU MAY RETURN THE PRODUCT TO MCAFEE OR THE PLACE OF
PURCHASE FOR A FULL REFUND.
Contents
Preface
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Overview
5
5
5
6
1:
2:
3:
4:
5:
6:
19
.
.
.
.
.
.
.
.
. .
. .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
19
20
21
22
23
. 23
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Remote queries
25
Persistent queries . . . . . . . . . . . . . . . . . . . . . . . . .
Ad-hoc queries . . . . . . . . . . . . . . . . . . . . . . . . . .
Create an ad-hoc query from a query definition . . . . . . . . . .
Get information about registered databases and tables . . . . . . .
Queries with joins . . . . . . . . . . . . . . . . . . . . . . . . .
Retrieve hierarchical query results . . . . . . . . . . . . . . . .
Limit query result depth . . . . . . . . . . . . . . . . . . . .
Remote query commands . . . . . . . . . . . . . . . . . . . . . .
Ad-hoc query reference . . . . . . . . . . . . . . . . . . . . . . .
General query datatypes . . . . . . . . . . . . . . . . . . .
General S-Expression operations . . . . . . . . . . . . . . . .
S-Expression operator and datatype combinations . . . . . . . . .
Special ePolicy Orchestrator data types . . . . . . . . . . . . . .
Special ePolicy Orchestrator operators . . . . . . . . . . . . . .
Special ePolicy Orchestrator operator and type combinations . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Index
.
.
.
.
.
.
.
.
25
26
27
28
29
29
30
31
31
31
32
34
34
35
37
39
Preface
This guide provides the information you need to configure, use, and maintain your McAfee product.
Contents
About this guide
Finding product documentation
Audience
McAfee documentation is carefully researched and written for the target audience.
The information in this guide is intended primarily for:
Administrators People who implement and enforce the company's security program.
Users People who use the computer where the software is running and can access some or all of
its features.
Conventions
This guide uses the following typographical conventions and icons.
Book title or Emphasis Title of a book, chapter, or topic; introduction of a new term; emphasis.
Bold
Commands and other text that the user types; the path of a folder or program.
Code
A code sample.
User interface
Words in the user interface including options, menus, buttons, and dialog
boxes.
Hypertext blue
Preface
Finding product documentation
Do this...
User documentation
KnowledgeBase
Overview
Version 4.6 of ePolicy Orchestrator introduces a Web API that adds scripting and automation
capabilities to common management activities such as user and System Tree maintenance and data
import and export.
In this guide, we will explain what the ePolicy Orchestrator Web API is, how to use it, and walk you
through a few exampls using a Python client. Finally, we will take a deeper look at some key
commands, including an extensive description of the query system.
Contents
Web API basics
Discovering available commands through URLs
An example task with the Web API
Python client basics
Web API Python script requirements
Discovering available commands in Python
Additional documentation included with the Web API
Key commands
First, we will take a look at the syntax for the request URLs provided in ePolicy Orchestrator to
illustrate the core capabilities of the Web API.
> wget -q -O - --no-check-certificate --user=ga --password=ga "https://localhost:8443/remote/
core.help"
Overview
Web API basics
Parameter
Description
-q
-O -
--no-check-certificate
--user
--password
In the examples provided in this document, you will see the ePolicy
Orchestrator server identifed as "localhost" and the destination port
identified as "8443" (the default). You need to replace these with the
server name and port number of your own installation.
The user in each example is "ga", a global administrator who has permission to execute all commands.
Web API commands follow all role-based permissions as enforced through the ePolicy Orchestrator
graphical interface.
The Web API is used primarily for two purposes:
Scripts using the Web API can be run from any computer that can connect to the ePolicy Orchestrator
server. For security reasons, they should not be run on the same computer as the ePolicy Orchestrator
server itself.
Before any commands can be run, you must authenticate with an ePolicy Orchestrator server.
General syntax
The general syntax for a commend sent via HTTPS is:
https://<server>:<port>/remote/<command>?<arg1>=<val1>&<arg2>=<val2>
Output options
By default, commands return output in a human-readable format. When scripting, however, you
usually want commands to return data in a more machine-readable format. This is controlled with the :
output parameter.
https://localhost:8443/remote/core.help?:output=json
This returns data in JavaScript Object Notation (JSON) format. Other options include verbose
(default), terse, and xml. These arguments must be supplied as all lowercase text. In addition to :
output, :locale and :validation parameters are available.
Overview
Discovering available commands through URLs
Values
:output
:locale
:validation
This returns a list that looks similar to the following. This exact list of commands will change
depending on your permissions and the extensions installed.
core.addPermSetsForUser userName permSetName - Adds permission set(s) to specified user
core.addUser userName password [fullName=<>] [email=<>] [phoneNumber=<>] [notes=<>]
[disabled=<>] [admin=<>] - Adds a user to the system
core.executeQuery queryId [database=<>] - Executes a SQUID query and returns the results
core.exportPermissionSets - Exports all permission sets.
core.help [command] [prefix=<>] - Displays a list of all commands and help strings.
core.importPermissionSets file [overwrite] - Imports permission sets.
core.listDatatypes [type] - Displays all registered datatypes and operations for those types
that the user is permitted to see.
core.listPermSets [userName] - List permission sets in the system
core.listQueries - Displays all queries that the user is permitted to see.
core.listTables [table] - Displays all SQUID tables that the user is permitted to see.
core.listUsers [permSetName] - List users in the system
core.purgeAuditLog [age] [unit] - Purge the audit log by age
core.removePermSetsForUser userName permSetName - Removes permission set(s) from a specified
user
core.removeUser userName - Removes a user from the system
core.updateUser userName [password=<>] [windowsUserName=<>] [windowsDomain=<>] [subjectDN=<>]
[newUserName=<>] [fullName=<>] [email=<>] [phoneNumber=<>] [notes=<>] [disabled=<>]
[admin=<>] - Updates an existing user
scheduler.cancelServerTask taskLogId - Terminates a currently running task
scheduler.getServerTask taskName - Gets details about a specific server task
scheduler.listAllServerTasks - Displays all server tasks
scheduler.listRunningServerTasks - Get the list of all running server tasks.
scheduler.runServerTask taskName - Runs a server task and returns the task log ID.
scheduler.updateServerTask taskName [status] - Enables or disables a server task (by default
status='enabled')
tasklog.listMessages taskLogId - Lists the messages for the specified task log entry
tasklog.listSubtasks taskLogId - Lists subtasks of a specified task log entry
tasklog.listTaskHistory [taskName] [taskSource] [maxRows] [age] [unit] - Lists task log
entries, optionally filtered by task name, task ID or task source
tasklog.listTaskSources - Lists the task sources
tasklog.purge [age] [unit] - Purges the Server Task Log beyond a given age and time unit
The object, command name, required and optional arguments, and a brief description are all included.
Optional arguments are enclosed in square brackets ("[" and "]").
Overview
An example task with the Web API
It can also be used to request more detailed information about specific commands. For example,
> wget -q -O - --no-check-certificate --user=ga --password=ga https://localhost:8443/remote/
core.help?command=core.listQueries
There are three required arguments: the group ID, the ID for the product you want to assign, and
the object ID of the policy to be assigned. You could also reset the inheritance, but that argument
is not required, and we will not use it in this example.
2
10
Overview
Python client basics
Next, you need to retrieve the product ID and policy object ID by using policy.find.
> wget -q -O - --no-check-certificate --user=ga --password=ga "https://localhost:8443/
remote/policy.find?searchText=quarantine"
Since policy.find returned two results, you need to choose one. For purposes of this example,
use the My Default policy. You've now obtained all the information you need to make the group
assignment. Finally, call policy.assignToGroup:
> wget -q -O - --no-check-certificate --user=ga --password=ga
"https://localhost:8443/remote/policy.assignToGroup?
groupId=7&productId=VIRUSSCAN8700&objectId=307"
This returns:
OK:
True
Commands that operate on a single item will return True or False indicating the command's
success or failure.
Commands that operate on several items return the number of items that succeeded.
11
Overview
Web API Python script requirements
Notes on parameters
Some commands such as system.clearTag can take a comma-delimited list of values as a parameter.
If you want to embed spaces in this list, you must enclose the entire list in quotes.
mysession.system.clearTag("System1, System2, System3","oldTag")
Any parameter requiring a file name uses the file:///c:\path\to\file format used in URLs.
After you complete these two tasks, the remainder of the script can function as desired.
12
Overview
Web API Python script requirements
Make sure the mcafee.py file is stored in either the same folder as your script, or in the Python
module search path.
Import the client code into your script with the following command:
import mcafee
This command imports the client code, which includes a method that takes connection information,
establishes a session with the indicated server, and returns a session object.
Communicate with the server with the mcafee.client command and between four and six
parameters.
Table 1-2 mcafee.client parameters
Parameter Description
server
A string containing the name of the server. Do not include the https:// prefix. If
your server name is https://myserver, put myserver in this parameter.
port
A string containing the port the server uses. This is typically 443 for HTTPS
connections and 80 for HTTP connections, but can differ if your server is configured
differently.
username
password
protocol
[optional] A string containing the protocol. The default is HTTPS but HTTP is another
valid option.
outputtype [optional] A string containing the output type returned from commands. This value
defaults to json but verbose, terse, and xml are other valid values.
For example, if you normally log on to an ePolicy Orchestrator server named ourcompanyserver on
port 443 with the user name adminfred and a password of notmydOgsname37, your Python
command to log on to the same server in the same fashion would be:
mysession = mcafee.client("ourcompanyserver","443","adminfred","notmydOgsname37")
The mysession variable stores the session information used for all later commands in that script.
For example, if the next thing you wanted to do in the script was to list all the currently running
server tasks, the command would be:
mysession.scheduler.listRunningServerTasks()
13
Overview
Discovering available commands in Python
Determine the list of modules available to you using the Python dir() command.
>>> dir(mysession)
There are a number of attributes in there, but what you should be looking for are the names at the
end without leading underscores. In this example, these are core, help, scheduler, and tasklog.
These are the objects available to you that contain commands you can execute. The names with
leading underscores are internal to either the client or Python itself.
2
To find out the list of commands in a given module, use the dir() command passing the module as
a parameter.
>>> dir(mysession.scheduler)
This returns a list of attributes and commands in the scheduler module. The list looks like this:
['__doc__', '__getattr__', '__init__', '__module__', '_invoker', '_module',
'cancelServerTask', 'getServerTask', 'listAllServerTasks', 'listRunningServerTasks',
'runServerTask', 'setServerTaskStatus']
As in the previous step, look for names without leading underscores. In this case, there are six
commands: cancelServerTask, getServerTask, listAllServerTasks, listRunningServerTasks,
runServerTask, and setServerTaskStatus.
3
Once you've found a command you're interested in, use help() and pass the command as a
parameter.
>>> mysession.help('scheduler.listRunningServerTasks')
This lists the command name and parameters (in this case there are none), a description of what it
does, and the permission required to execute it.
Performing similar steps for any command you find will help determine all the capabilities available for
your scripts.
14
Overview
Additional documentation included with the Web API
Topic
FAQ.html
setup.html
Key commands
Some commands are more commonly used than others. Being familiar with their syntax will help you
create scripts quickly.
The following tables list commonly used commands with their syntax and description. Each table
covers a different functional area.
Table 1-4 Commands for searching, querying, and listing
Command
core.executeQuery
core.help
core.listDatabases
core.listQueries
core.listTables
policy.find
repository.find
system.find
Syntax
Description
core.executeQuery queryId
[database=<>]
core.executeQuery target=<>
[select=<>] [where=<>]
[order=<>] [group=<>]
[database=<>] [depth=<>]
[joinTables=<>]
core.help [command]
[prefix=<>]
core.listDatabases
core.listQueries
core.listTables [table=<>]
policy.find searchText
repository.find searchText
system.find searchText
15
Overview
Key commands
core.importPermissionSets
core.exportPermissionSets
system.importSystem
repository.checkInPackage
Syntax
core.addUser userName password
[fullName=<>] [email=<>]
[phoneNumber=<>] [notes=<>]
[disabled=<>]
[
Description
Adds a user to the system.
Authentication parameters
are mutually exclusive:
either password,
windowsUserName/
windowsDomain, or
subjectDN can be specified.
core.importPermissionSets file
[overwrite]
core.exportPermissionSets
system.importSystem fileName
branchNodeID [allowDuplicates]
[uninstallRemoved] [pushAgent]
[pushAgentForceInstall]
[pushAgentSkipIfInstalled]
[pushAgentSuppressUI]
[pushAgentInstallPath]
[pushAgentPackagePath]
[pushAgentDomainName]
[pushAgentUserName]
[pushAgentPassword]
[deleteIfRemoved]
[createNewInLostAndFound]
[flattenTreeStructure
repository.checkInPackage
packageLocation branch [option]
[moveToPrevious]
[allowUnsignedPackages]
core.addPermSetsForUser
system.applyTag
system.setUserProperties
16
Syntax
core.updateUser userName
[password=<>]
[windowsUserName=<>]
[windowsDomain=<>]
[subjectDN=<>] [newUserName=<>]
[fullName=<>]
[email=<>] [phoneNumber=<>]
[notes=<>]
[disabled=<>] [admin=<>]
core.addPermSetsForUser userName
permSetName
system.applyTag names tagName
system.setUserProperties name
[description] [customField1]
[customField2] [customField3]
[customField4]
Description
Updates an existing user.
Authentication parameters are
mutually exclusive: either
password, windowsUserName/
windowsDomain, or subjectDN
can be specified.
Overview
Key commands
Syntax
system.deployAgent
Description
policy.assignToSystem
policy.assignToSystem names
productId typeId objectId
[resetInheritance]
Syntax
clienttask.run
system.wakeupAgent
repository.pull
scheduler.cancelServerTask
scheduler.runServerTask
Description
scheduler.cancelServerTask taskLogId
Terminates a currently
running task.
scheduler.runServerTask taskName
core.purgeAuditLog
system.delete
tasklog.purge
Syntax
Description
commonevent.purgeEvents queryId
[unit]
core.purgeAuditLog [age] [unit]
system.delete names [uninstall]
17
Take a tag as input and send an agent wakeup call to all systems with that tag.
Import computers from an external file and adding them to the System Tree.
Export policies and client tasks from one ePolicy Orchestrator server and import them into another.
Contents
Example 1: Tagging systems from a list
Example 2: Automating repetitive tasks on managed systems
Example 3: Automating user management
Example 4: Importing computers from external sources
Example 5: Importing and exporting data
Example 6: Automated maintenance of the System Tree
19
That's all there is to it. There are some assumptions made in this script: the input file exists, it lists
one system per line, the systems are listed by name or IP address, and the tag named myTag exists. A
more robust script would handle those assumptions, but that would complicate this example. Now, to
examine the various sections in detail.
import mcafee
This line imports the provided McAfee Python module (mcafee.py), which means that this file should
be kept in the same directory as your script.
mc = mcafee.client('localhost','8443','ga','ga')
Here is where you create the connection to the ePolicy Orchestrator server by specifying the server
name, connection port, username, and password, in that order. This initialization function can take up
to two more parameters that specify the protocol and the presentation of the output. The full
parameter list is:
mc = mcafee.client('yourservername','port','username','password', 'protocol',
'outputtype')
The protocol defaults to https but you may specify http if SSL is disabled on your ePolicy
Orchestrator server.
The outputtype determines the format of output from commands as described in Web API Basics.
With those two lines, you've established a connection to your server. Next, you need to create your file
handle in read-only mode.
file = open('C:/path/to/myfile.txt')
Finally, you need to iterate through the file and run the command system.applyTag to each system in
the file:
for line in file:
mc.system.applyTag(line, "myTag")
After finishing the loop, each system in the file should now have the tag myTag applied.
This script takes a single argument as input. It then uses the system.find command to search for all
computers that have the corresponding tag. You could input something other than a tag, however, as
the system.find description reads: "Find Systems in the ePolicy Orchestrator tree by name, IP
address, MAC address, user name, AgentGUID or tag."
20
By default system.find returns a list of JSON-formatted systems, but the script ensures this by
specifying JSON output in the ePolicy Orchestrator connection parameters. Because JSON data
structures map directly to Python data types, in Python you can simply assign the results of the find
command to a Python variable.
The script above uses the EPOComputerProperties.ParentID property to send to the
system.wakeupAgent command, but as that command also takes a name, that line could have been
written as:
id = system['EPOComputerProperties.ComputerName']
Also, since system.wakeupAgent also accepts a list of names or IDs as input, you could have built a
comma-delimited string and sent the list to the command directly.
It helps to examine the output from the core.listUsers command to see the available properties.
This script uses the disabled, admin and name properties to achieve its purpose. Note that the
core.removeUser command needs administrator privileges to execute. Required privileges for each
command are listed in its detailed help.
The core.listUsers command returns different values for the authType in machine-readable formats
than it does in human-readable formats such as used in the user interface.
Human readable
Machine readable
MFS authentication
pwd
cert
Windows authentication
ntlm
21
First, we need to know where to add the systems. The script uses the system.findGroups()
command to search for it by name, and from that obtain the group ID. The systems are added with
the detectedsystem.add command. This command has numerous optional parameters:
detectedsystem.add sourceID sourceType MAC IPAddress [IPSubnet][IPSubnetMask][dnsName]
[OSPlatform] [OSFamily] [OSVersion]
[domain] [netbiosName][netbiosComment] [users] [agentGUID] [detectedTime] [externalID]
You can add optional parameters in order (using non-sensical values for parameters you aren't
providing) which would look look like:
mc.detectedsystem.add(sourceId, sourceType,sysProps[0], sysProps[1], 0.0.0.0, 0.0.0.0,
sysProps[2], '', '',
'', sysProps[4])
Or you can assign parameters by name, as done for the dnsName and domainName parameters in the
script above. Note that the parameters sourceID and sourceType are arbitrary values defined by
whomever is adding the systems. These are stored in the database so that we can tell what source
detected or added any given system.
The return value of this command is the ID of the newly-added detected system. You use this ID as
input to the next command () which adds detected systems into the System Tree.
detectedsystem.addToTree UIDs branchNodeID [allowDuplicates] [dirSort]
By default, the system will not be added if it's a duplicate nor will it be automatically sorted, but you
can override these behaviors if desired. This script accepts the defaults and, using the newly-obtained
detected system ID and the group ID found earlier, moves this system into the System Tree.
22
First, retrieve the product ID by searching for a policy containing the string 'McAfee Agent'. Using
that product ID, you can then export all of the client tasks and policies for that product. Finally, create
a connection to a second ePolicy Orchestrator server (mc2) and run the corresponding import
commands on that server.
23
id = system['EPOComputerProperties.ParentID']
mc.system.resort(id)
This should be fairly straightforward given the previous scenarios. Here we introduce a new command
epogroup.findSystems which finds all systems in a given group. The last parameter determines
whether to search all subgroups as well. In this case, we set this parameter to true, iterating through
all systems found under Lost & Found and any of its subgroups and reapplying the sorting rules to
them.
24
Remote queries
ePolicy Orchestrator remote commands allow you to query for data remotely using the Web API. These
commands allow you to execute persistent queries that exist in the ePolicy Orchestrator database as
well as dynamic, customer-defined ad-hoc queries.
Contents
Persistent queries
Ad-hoc queries
Queries with joins
Remote query commands
Ad-hoc query reference
Persistent queries
A persistent query is a query that is accessible via the Queries and Reports page in the ePolicy
Orchestrator user interface.
Persistent queries include both pre-installed queries and queries created by users. To remotely execute
a persistent query, you must know the query's ID.
In all examples, the first two lines contain the URL and Python forms of
the command.
25
Remote queries
Ad-hoc queries
Ad-hoc queries
Ad-hoc queries are performed entirely remotely, and do not rely on a query stored in an ePolicy
Orchestrator database.
In an ad-hoc query, you specify the target of the query and up to four parameters.
Table 3-1 Ad-hoc query parameters
Clause
Description
Behavior if omitted
select
group
order
26
Remote queries
Ad-hoc queries
This query returns the CmdName and EndTime for all audit log entries. The results are grouped
alphabeticallyby the CmdName, then by the EndDate.
URL: https://servername:port/remote/core.executeQuery?target=OrionAuditLog&select=(select
OrionAuditLog.CmdName.OrionAuditLog.EndTime)&group=(group.OrionAuditLog.CmdName
OrionAuditLog.EndTime)
Python: mysessioncore.executeQuery(target="OrionAuditLog", select="(select
OrionAuditLog.CmdName OrionAuditLog.EndTime)",
group="(group OrionAuditLog.CmdName OrionAuditLog.EndTime)");
This query returns all the OrionTaskLog entries that were created by the GA user. The results are listed
in ascending order of the task StartDate.
URL: https://servername:port/remote/core.executeQuery?target=OrionTaskLogTask&where=(where
( eq ( OrionTaskLogTask .UserName "ga" ))) &order=(order (asc OrionTaskLogTask.StartDate) )
Python: mysession.core.executeQuery(target="OrionTaskLogTask", where="(where ( eq
( OrionTaskLogTask .UserName "ga" )))", order="(order (asc OrionTaskLogTask.StartDate) )");
Example
A typical exported query definition:
<query>
<name language="en">My AuditLogQuery</name>
<description language="en"></description>
<property name="target">OrionAuditLog</property>
<property name="tableURI">query:table?orion.table.columns=OrionAuditLog.UserName
%3AOrionAuditLog.CmdName%3A
OrionAuditLog.Success
%3AOrionAuditLog.StartTime&orion.table.order.by=OrionAuditLog.CmdName
&orion.table.order=asc</property>
<property name="conditionURI">query:condition?orion.condition.sexp=%28+where+%28+olderThan+
OrionAuditLog.EndTime+3600000++%29+%29</property>
<property name="summaryURI">query:summary?
orion.sum.query=false&orion.query.type=table.table</property>
</query>
27
Remote queries
Ad-hoc queries
The target attribute is used directly as the target parameter of the ad-hoc query.
The tableURI attribute contains S-Expressions that can be used as part of the selection, as well as
part of the order parameter.
The conditionURI attribute contains the S-Expression that can be used as the where parameter.
Keep in mind that the exported form of the query contains strings that are url-encoded. To form a
valid query string, you will need to decode the url-encoded characters. For example, "+" is used for a
single space " ", %28 is an opening parenthesis "(", %29 is a closing parenthesis ")", and so on.
Thus the equivalent ad-hoc query would be this.
https://servername:port/remote/core.executeQuery?target=OrionAuditLog&select=(select
OrionAuditLog.UserName OrionAuditLog.CmdName OrionAuditLog.Success
OrionAuditLog.StartTime)&where=(where(olderThan OrionAuditLog.EndTime
36000000))&order=(order(asc OrionAuditLog.CmdName))
Or in Python, this.
mysession.core.executeQuery(target="OrionAuditLog",
select="(select OrionAuditLog.UserName OrionAuditLog.CmdName OrionAuditLog.Success
OrionAuditLog.StartTime)",
where="(where(olderThan OrionAuditLog.EndTime 36000000))",
order="(order(asc OrionAuditLog.CmdName))");
Example output
The following output is from the core.listTables command run on the OrionAuditLog table.
Name: Audit Log Entries
Target: OrionAuditLog
Type: target
Database Type:
Description: Retrieves information
Columns:
Name
Type
Select?
--------- ------------- ------AutoId
int
false
UserId
int
false
UserName string_lookup true
Priority enum
true
CmdName
string_lookup true
Message
string
true
Success
boolean
true
StartTime timestamp
true
EndTime
timestamp
true
Related Tables:
Name
---Foreign Keys: None
28
GroupBy?
-------false
false
true
true
true
false
true
true
true
Order?
-----true
true
true
true
true
true
true
true
true
Number?
------true
true
false
false
false
false
false
false
false
Remote queries
Queries with joins
The command lists the columns, their types, whether or not the column can be used in the select,
condition, group, or order parameters, and whether the column is a number. It also lists any
registered related tables that can be joined with the joinTables parameter.
29
Remote queries
Queries with joins
Example
The following is an example of executing a simple join between the OrionTaskLog and the
OrionTaskLogMessage tables. You can see from the output that the core.executeQuery command
returned each top-level object (the OrionTaskLogTask record) and its two associated message
records. For this example, the output is shown as xml to highlight the hierarchical arrangement of the
results.
OK:
<?xml version="1.0" encoding="UTF-8"?>
<result>
<list>
<row>
<OrionTaskLogTask.Name>New Task</OrionTaskLogTask.Name>
<OrionTaskLogTask.StartDate>2010-11-23T13:01:37-08:00</OrionTaskLogTask.StartDate>
<OrionTaskLogTask.EndDate>2010-11-23T13:01:37-08:00</OrionTaskLogTask.EndDate>
<OrionTaskLogTask.UserName>ga</OrionTaskLogTask.UserName>
<OrionTaskLogTask.Status>0</OrionTaskLogTask.Status>
<OrionTaskLogTask.TaskSource>scheduler</OrionTaskLogTask.TaskSource>
<OrionTaskLogTask.Duration>493</OrionTaskLogTask.Duration>
<OrionTaskLogTaskMessage>
<list>
<row>
<OrionTaskLogTaskMessage.Message>Purge audit log</OrionTaskLogTaskMessage.Message>
</row>
<row>
<OrionTaskLogTaskMessage.Message>Purge audit log (Purge log records older than: 1 days)</
OrionTaskLogTaskMessage.Message>
</row>
</list>
</OrionTaskLogTaskMessage>
</row>
</list>
</result>
30
Remote queries
Remote query commands
Command
Syntax
Description
core.executeQuery
core.executeQuery queryId
[database=<>]
core.executeQuery target=<>
[select=<>] [where=<>] [order=<
>] [group=<>] [database=<>]
[depth=<>] [joinTables=<>]
core.listDatabases core.listDatabases
core.listTables
core.listTables [table]
core.listQueries
core.listQueries
core.listDatatypes core.listDatatypes
Type
Description
Int
An integer
string_lookup
Enum
Mac
A MAC address
Long
A long value
Float
A float value
Timespan
An SQL timespan
boolean
A Boolean value
string_enum
31
Remote queries
Ad-hoc query reference
Table 3-3
Type
Description
ipv4
An IPv4 address
ipv6
An IPv6 address
32
Operator
Description
Example
and
or
not
eq
ne
gt
lt
ge
le
is_Blank
not_isBlank
in
contains
notContains
Returns the row if the column value does (where (notContains OrionAuditLog
.UserName "ga"))
not contain the stubstring argument
value.
startsWith
endsWith
Remote queries
Ad-hoc query reference
Table 3-4
Operator
Description
Example
like
newerThan
olderThan
between
beforeNow
match_any
(where(match_any
EPOComputerProperties.IPV4x (ipv4
"192.168.1.1")))
notBetween
(where (notBetween
EPOComputerProperties.IPV4x (ipv4
"192.168.1.1")(ipv4 "192.168.255.
255")))
not_in_subnet
(where (not_in_subnet
EPOComputerProperties.IPV4x (ipv4
"255.255.255.0" ) 25 ))
in_subnet
(where (in_subnet
EPOComputerProperties.IPV4x (ipv4
"255.255.255.0" ) 25 ))
(where (not_in_ipv6_subnet
EPOComputerProperties.IPV6 (ipv6 "0
.0.0.0") 1))
(where(not_match_any
EPOComputerProperties.IPV6 (ipv6
"fc00::/7")))
Table 3-5
Selection-only S-Expressions
Operator Description
Example
Distinct
If you use an order clause with select distinct, you must include the order columns in
the selection.
Top N
33
Remote queries
Ad-hoc query reference
34
Type
Description
applied_tags
byte
eventID
group
multiselect_group
managedState
A Boolean value used for the managed status of a device in the System
Tree.
Megabytes
optionGroup_enum
Percentagefromstring
Remote queries
Ad-hoc query reference
Table 3-6
Type
Description
Policycolumn
productVersion
Rsdmac
Used for MAC addresses. Most often associated with detected systems.
Rsdoui
string_lookupWithResolver Used to allow the user to choose from a list of known string values.
Threatcategory
DATversion
engineVersion
datVersion
Operator
Description
Example
hasTag
(hasTag EPOLeafNode.AppliedTags
'fullTagName')
containsTag
(containsTag EPOLeafNode
Evaluates to true if any
tags applied to the system .AppliedTags 'partialTagName')
contain the specified partial
tag name.
hasTagExcluded
(hasTagExcluded EPOLeafNode
Evaluates to true if the
specified tag is excluded on .AppliedTags 'excludedTagName')
the system.
doesNotHaveTag
(doesNotHaveTag EPOLeafNode
.AppliedTags 'fullTagName')
doesNotHaveAnyTag
(doesNotHaveAnyTag EPOLeafNode
.AppliedTags)
childOf
descendsFrom
(descendsFrom EPOLeafNode
.parentId <nodeId1> <nodeId2> ...
)
stateEq
(stateEq EPOLeafNode
.ManagedState
["managed"|"unmanaged"])
version_eq
(version_eq EPOMasterCatalog
.ProductVersion '3.1.4.1')
35
Remote queries
Ad-hoc query reference
Table 3-7
Operator
Description
Example
version_neq
(version_neq EPOMasterCatalog
.ProductVersion '3.1.4.1')
version_ge
(version_ge EPOMasterCatalog
.ProductVersion '3.1.4.1')
version_lt
threatcategory_belongs
(threatcategory_belongs
EPOEvents.ThreatCategory 'av')
threatcategory_not_belongs
(threatcategory_not_belongs
EPOEvents.ThreatCategory 'av')
withinRepositoryDatVersion
36
Remote queries
Ad-hoc query reference
37
Index
A
about this guide 5
authentication 13
C
commands
clienttask.export 23
clienttask.importClientTask 23
clienttask.run 15
commonevent.purgeEvents 15
core.addPermSetsForUser 15
core.addUser 15
core.executeQuery 15, 25, 27, 2931
core.exportPermissionSets 15
core.help 9, 14, 15
core.importPermissionSets 15
core.listDatabases 15, 26, 28, 31
core.listDatatypes 26, 31
core.listQueries 15, 25, 31
core.listTables 15, 26, 28, 29, 31
core.listUsers 21
core.purgeAuditLog 15
core.removeUser 21
core.updateUser 15
detectedsystem.add 22
detectedsystem.addToTree 22
dir 14
epogroup.findSystems 23
help 14
mcafee.client 13
policy.assignToGroup 10
policy.assignToSystem 15
policy.export 23
policy.find 10, 15, 23
policy.importPolicy 23
repository.checkInPackage 15
repository.find 15
repository.pull 15
scheduler.cancelServerTask 15
scheduler.listRunningServerTasks 13
scheduler.runServerTask 15
system.applyTag 19
system.ApplyTag 15
commands (continued)
system.delete 15
system.deployAgent 15
system.find 15, 20
system.findGroups 10, 22, 23
system.importSystem 15
system.resort 23
system.setUserProperties 15
system.wakeupAgent 15, 20
tasklog.purge 15
conventions and icons used in this guide 5
curl 7
D
datatypes
ePolicy Orchestrator specific 34
ePolicy Orchestrator specific operator combinations 37
reference 31, 34
s-expression operator combinations 34
discover commands
Python client 14
URLs 9
documentation
audience for this guide 5
product-specific, finding 6
typographical conventions and icons 5
E
example
assigning policies 10
URL use 10
examples
automating repetitive tasks 20
automating user management 21
importing and exporting 23
importing computers 22
introduction 19
introductory 19
System Tree maintenance 23
H
help
retrieving command listings 9
39
Index
I
introduction
examples 19
K
key commands 15
M
McAfee ServicePortal, accessing 6
O
operators
ePolicy Orchestrator specific 35
ePolicy Orchestrator specific datatype combinations 37
reference 35
s-expression datatype combinations 34
s-expression reference 32
output type
JSON 7
terse 7
verbose 7
XML 7
P
parameter notes 11
password security 13
Python client
authenticating 13
discovering commands 14
importing into a script 13
script requirements 12
software requirements 11
using 11
Q
queries
ad-hoc 26
ad-hoc example created from query definition 27
ad-hoc reference 31
commands used in remote queries 31
datatype reference 31
example ad-hoc query 26
executing perisistent 25
joining tables 29
40
queries (continued)
joinTable argument 30
obtaining database information 28
obtaining table information 28
operator reference 31
operators used with s-expressions 32
order argument 27
performing ad-hoc 26
persistent 25
select argument 27, 29
specifying tables to join 29
trimming result sets 30
where argument 27
R
requirements
Python client 11
scripts 12
S
s-expressions
operator reference 32
operators used with datatypes 34
ServicePortal, finding product documentation 6
T
Technical Support, finding product information 6
U
URLs
discovering commands through 9
W
Web API
basics 7
calling with URLs 7
controlling output locale 7
introduction 7
output formats 7
overview 7
retrieving files with curl 7
return types 10
wget
example using 10