Skip to content

Commit

Permalink
doc: Mark up code as "vql", output as "json"
Browse files Browse the repository at this point in the history
  • Loading branch information
hillu committed Aug 22, 2023
1 parent a7ac29a commit 2e7fc45
Showing 1 changed file with 36 additions and 34 deletions.
70 changes: 36 additions & 34 deletions docs/references/vql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
You can use this to flatten a subquery as well:
```sql
```vql
SELECT array(a1={ SELECT User FROM Artifact.Windows.System.Users() }) as Users FROM scope()
```
Expand Down Expand Up @@ -393,7 +393,7 @@
The following returns the rows from the first query then the rows from
the second query.
```sql
```vql
SELECT * FROM chain(
a={ SELECT ...},
b={ SELECT ...},
Expand Down Expand Up @@ -558,7 +558,7 @@
The following will generate an event every 10 seconds.
```sql
```vql
SELECT Second FROM clock(period=10)
```
Expand Down Expand Up @@ -1497,7 +1497,7 @@
The following checks for 5 failed logons followed by a successful
logon.
```sql
```vql
LET failed_logon = SELECT EventData as FailedEventData,
System as FailedSystem
FROM watch_evtx(filename=securityLogFile)
Expand Down Expand Up @@ -1816,14 +1816,14 @@
In other words this:
```
```vql
LET X <= generate(query={ SELECT * FROM watch_etw(...) })
```
Will attempt to enumerate the target query into an array and is
equivalent to:
```
```vql
LET X <= SELECT * FROM watch_etw(...)
```
Expand Down Expand Up @@ -1876,13 +1876,14 @@
### Example
```sql
```vql
select get(item=[dict(foo=3), 2, 3, 4], member='0.foo') AS Foo from scope()
```
```json
[
{
"Foo": 3
}
{
"Foo": 3
}
]
```
Expand Down Expand Up @@ -1979,15 +1980,15 @@
By default globs do not expand environment variables. If you need to
expand environment variables use the `expand()` function explicitly:
```sql
```vql
glob(globs=expand(string="%SystemRoot%\System32\Winevt\Logs\*"))
```
### Example
The following searches the raw NTFS disk for event logs.
```sql
```vql
SELECT FullPath FROM glob(
globs="C:\Windows\System32\Winevt\Logs\*.evtx",
accessor="ntfs")
Expand Down Expand Up @@ -2209,7 +2210,7 @@
The following VQL returns the client's external IP as seen by the
externalip service.
```sql
```vql
SELECT Content as IP from http_client(url='http://www.myexternalip.com/raw')
```
Expand Down Expand Up @@ -2708,7 +2709,7 @@
encoded as an array of 8 bytes which makes it easy to format using the
`format()` function:
```
```vql
format(format="%x:%x:%x:%x:%x:%x:%x:%x", value)
```
type: Function
Expand Down Expand Up @@ -2934,7 +2935,7 @@
clause as a form of debugging (It is basically equivalent to the
print statement of other languages).
```sql
```vql
SELECT * FROM glob(...)
WHERE log(message="Value of OSPath is %v", args=OSPath)
```
Expand Down Expand Up @@ -3246,7 +3247,7 @@
The following query lists all the processes and shows the largest
bash pid of all bash processes.
```SQL
```vql
SELECT Name, max(items=Pid) as LargestPid from pslist() Where Name =~ 'bash' group by Name
```
type: Function
Expand Down Expand Up @@ -3324,7 +3325,7 @@
The following query lists all the processes and shows the smallest
bash pid of all bash processes.
```SQL
```vql
SELECT Name, min(items=Pid) as SmallestPid from pslist() Where Name =~ 'bash' group by Name
```
type: Function
Expand Down Expand Up @@ -3730,7 +3731,7 @@
The following stacks the result from a
`Windows.Applications.Chrome.Extensions` artifact:
```sql
```vql
SELECT count(items=User) As TotalUsers, Name
FROM parse_csv(filename="All Windows.Applications.Chrome.Extensions.csv")
Order By TotalUsers
Expand Down Expand Up @@ -3807,7 +3808,7 @@
### Example
```sql
```vql
SELECT System.TimeCreated.SystemTime as Timestamp,
System.EventID.Value as EventID,
EventData.ImagePath as ImagePath,
Expand Down Expand Up @@ -4137,7 +4138,7 @@
using parse_string_with_regex() to further break the block into
fields.
```sql
```vql
SELECT parse_string_with_regex(
string=Record,
regex=['Package:\\s(?P<Package>.+)',
Expand Down Expand Up @@ -4280,18 +4281,19 @@
I practice you can use this to update server settings - for
example, consider the client event monitoring state.
```text
```vql
SELECT get_client_monitoring() FROM scope()
[
```
```json
[
{
"get_client_monitoring": {
"artifacts": [
"Generic.Client.Stats"
]
}
"get_client_monitoring": {
"artifacts": [
"Generic.Client.Stats"
]
}
}
]
]
```
Suppose we wish to add a new artifact, we can patch it with the json:
Expand All @@ -4302,7 +4304,7 @@
This can then be immediately pushed to `set_client_monitoring()`
to update the monitoring state.
```
```vql
SELECT set_client_monitoring(value=patch(
item=get_client_monitoring(),
patch=[dict(op="add", path="/artifacts/0", value="Windows.Events.DNSQueries")]))
Expand Down Expand Up @@ -5110,7 +5112,7 @@
### Example
```sql
```vql
SELECT 1+1 As Two FROM scope()
```
type: Plugin
Expand Down Expand Up @@ -5711,7 +5713,7 @@
You can also provide a string, and `timestamp()` will try to parse
it by guessing what it represents. For example
```
```vql
SELECT timestamp(string='March 3 2019'),
timestamp(string='07/25/2019 5pm')
FROM scope()
Expand Down Expand Up @@ -6375,7 +6377,7 @@
For example the following can chose from a legacy query or a
modern query based on the plugin version:
```
```vql
SELECT * FROM if(
condition=version(plugin="glob") >= 1,
then=NewQuery,
Expand Down

0 comments on commit 2e7fc45

Please sign in to comment.