Skip to content

Commit

Permalink
common/doc: remove trailing whitespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
MrAnno committed Oct 23, 2024
1 parent c6d4ae7 commit 16305e8
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 34 deletions.
14 changes: 7 additions & 7 deletions common/src/database/postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ impl PostgresDatabase {
client
.query(
format!(
r#"SELECT *
FROM heartbeats
r#"SELECT *
FROM heartbeats
JOIN subscriptions ON subscriptions.uuid = heartbeats.subscription
WHERE {} = $1
AND subscription = $2"#,
Expand All @@ -170,8 +170,8 @@ impl PostgresDatabase {
client
.query(
format!(
r#"SELECT *
FROM heartbeats
r#"SELECT *
FROM heartbeats
JOIN subscriptions ON subscriptions.uuid = heartbeats.subscription
WHERE {} = $1"#,
field
Expand Down Expand Up @@ -572,7 +572,7 @@ impl Database for PostgresDatabase {
.await?
.query(
r#"
SELECT *
SELECT *
FROM subscriptions
"#,
&[],
Expand All @@ -596,7 +596,7 @@ impl Database for PostgresDatabase {
.get()
.await?
.query_opt(
r#"SELECT *
r#"SELECT *
FROM subscriptions
WHERE uuid = $1 OR name = $1"#,
&[&identifier],
Expand Down Expand Up @@ -626,7 +626,7 @@ impl Database for PostgresDatabase {
ignore_channel_error, princs_filter_op, princs_filter_value, outputs, locale,
data_locale)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20)
ON CONFLICT (uuid) DO UPDATE SET
ON CONFLICT (uuid) DO UPDATE SET
version = excluded.version,
revision = excluded.revision,
name = excluded.name,
Expand Down
24 changes: 12 additions & 12 deletions common/src/database/sqlite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
// license (MIT), we include below its copyright notice and permission notice:
//
// The MIT License (MIT)
//
//
// Copyright (c) 2015 Skyler Lipthay
//
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Expand Down Expand Up @@ -125,7 +125,7 @@ impl SQLiteDatabase {
)?;
let rows = statement.query_and_then(&[(":field_value", &field_value), (":subscription", &value)], row_to_heartbeat)?;

let mut heartbeats = Vec::new();
let mut heartbeats = Vec::new();
for heartbeat in rows {
heartbeats.push(heartbeat?);
}
Expand All @@ -134,15 +134,15 @@ impl SQLiteDatabase {
let mut statement = conn.prepare(
format!(
r#"SELECT *
FROM heartbeats
FROM heartbeats
JOIN subscriptions ON subscriptions.uuid = heartbeats.subscription
WHERE {} = :field_value"#,
field
)
.as_str()
)?;
let rows = statement.query_and_then(&[(":field_value", &field_value)], row_to_heartbeat)?;
let mut heartbeats = Vec::new();
let mut heartbeats = Vec::new();
for heartbeat in rows {
heartbeats.push(heartbeat?);
}
Expand Down Expand Up @@ -321,12 +321,12 @@ impl Database for SQLiteDatabase {
(None, None) => {
client.interact(move |conn| {
conn.execute("DELETE FROM bookmarks", [])
}).await
}).await
}
};
future.map_err(|err| anyhow!(format!("{}", err)))??;
Ok(())

}

async fn get_heartbeats_by_machine(
Expand Down Expand Up @@ -469,7 +469,7 @@ impl Database for SQLiteDatabase {
for (key, value) in heartbeats_cloned {
match value.last_event_seen {
Some(last_event_seen) => {
query_with_event
query_with_event
.execute(
params![
&key.machine,
Expand Down Expand Up @@ -561,7 +561,7 @@ impl Database for SQLiteDatabase {
:max_time, :max_envelope_size, :enabled, :read_existing_events, :content_format,
:ignore_channel_error, :princs_filter_op, :princs_filter_value, :outputs,
:locale, :data_locale)
ON CONFLICT (uuid) DO UPDATE SET
ON CONFLICT (uuid) DO UPDATE SET
version = excluded.version,
revision = excluded.revision,
name = excluded.name,
Expand Down Expand Up @@ -776,7 +776,7 @@ impl Database for SQLiteDatabase {
.interact(move |conn| {
conn.query_row(
r#"SELECT COUNT(machine)
FROM heartbeats
FROM heartbeats
WHERE subscription = :subscription"#,
&[(":subscription", &subscription_owned)],
|row| row.get(0),
Expand Down
2 changes: 1 addition & 1 deletion common/src/models/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ enabled = true
[outputs.config]
base = "/tmp/"
split_on_addr_index = 2
split_on_addr_index = 2
append_node_name = true
filename = "courgette"
Expand Down
28 changes: 14 additions & 14 deletions doc/subscription.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Subscription

A subscription enables a Windows Event Collector to retrieve a set of events from a set of machines using a dedicated configuration.
A subscription enables a Windows Event Collector to retrieve a set of events from a set of machines using a dedicated configuration.

The set of events is defined by a list of XPath filter queries. For example, here is a query list composed of a single query which retrieves all event logs within channels `Application`, `Security`, `Setup` and `System`:
```xml
Expand All @@ -24,7 +24,7 @@ In addition, each subscription is identified by a GUID called `uuid`, which is n

Each Windows machine configured to contact a Windows Event Collector server will send an `Enumerate` request to get a list of subscriptions. It will then create locally these subscriptions and fullfill them.

## Parameters
## Parameters

Subscriptions and their parameters are not defined in OpenWEC configuration file but in OpenWEC database. Therefore, you **must** use `openwec` cli to edit them. You should **never update subscription parameters directly in database**.

Expand Down Expand Up @@ -123,7 +123,7 @@ To use configuration files, edit them and then run `openwec subscriptions load`.

### Revisions

When using the `openwec subscriptions load` command, you can use the `--revision` flag to specify a revision string that represents the configuration version. For example, you can use the output of `git rev-parse --short HEAD` if your configuration files are versioned using `git`.
When using the `openwec subscriptions load` command, you can use the `--revision` flag to specify a revision string that represents the configuration version. For example, you can use the output of `git rev-parse --short HEAD` if your configuration files are versioned using `git`.

When a client retrieves its subscriptions, it also receives the associated revision strings. Later, when pushing events or sending heartbeats, the revision string is included as metadata. The revision string received by OpenWEC within events is called `ClientRevision` because it represents the revision "used" by the client at that time. The revision string is not used to compute the subscription version that clients use to determine whether the subscription has been updated since their last `Refresh`. This is because some configuration updates may only affect "server" parameters (i.e. outputs), and we do not want all clients to refresh the subscription unnecessarily. However, if the configuration update affects "client" parameters (such as query), the subscription version is updated and clients will retrieve the new version of the subscription configuration with the new revision string on the next `Refresh`.

Expand All @@ -147,7 +147,7 @@ You can disable all cli commands that edit subscriptions using the OpenWEC setti

List subscriptions in a "short" format. Each line represents a subscription, with its status (enabled or not), its name and its URI.

#### Usage
#### Usage

```
$ openwec subscriptions
Expand All @@ -156,7 +156,7 @@ $ openwec subscriptions
[+] Subscription-toto (/toto)
```

There are 3 subscriptions:
There are 3 subscriptions:
- A subscription named `Old subscription`, disabled with no URI defined.
- A subscription named `My-new-subscription`, enabled with no URI defined.
- A subscription named `Subscription-toto`, enabled with a URI set to `/toto`.
Expand All @@ -167,7 +167,7 @@ Otherwise, if a Windows machine sends an Enumerate request using URI `/toto`, it
### `openwec subscriptions new` (deprecated)

> [!WARNING]
> Using commands to manage subscriptions and there outputs is **deprecated** and will be removed in future releases. Use subscription configuration files instead.
> Using commands to manage subscriptions and there outputs is **deprecated** and will be removed in future releases. Use subscription configuration files instead.
This command enables you to create a new subscription.

Expand All @@ -191,7 +191,7 @@ You may add some using `openwec subscriptions output`, which is detailed in [Out
### `openwec subscriptions edit` (deprecated)

> [!WARNING]
> Using commands to manage subscriptions and there outputs is **deprecated** and will be removed in future releases. Use subscription configuration files instead.
> Using commands to manage subscriptions and there outputs is **deprecated** and will be removed in future releases. Use subscription configuration files instead.
This command enables you to edit an already existing subscription.

Expand Down Expand Up @@ -238,7 +238,7 @@ Subscription my-super-subscription
ContentFormat: Raw
IgnoreChannelError: true
Principal filter: Not configured
Outputs: Not configured
Outputs: Not configured
Enabled: false
Event filter query:
Expand All @@ -256,7 +256,7 @@ Event filter query:
### `openwec subscriptions duplicate` (deprecated)

> [!WARNING]
> Using commands to manage subscriptions and there outputs is **deprecated** and will be removed in future releases. Use subscription configuration files instead.
> Using commands to manage subscriptions and there outputs is **deprecated** and will be removed in future releases. Use subscription configuration files instead.
This command duplicates an existing subscription.

Expand Down Expand Up @@ -303,7 +303,7 @@ Event filter query:
### `openwec subscriptions export` (deprecated)

> [!WARNING]
> Using commands to manage subscriptions and there outputs is **deprecated** and will be removed in future releases. Use subscription configuration files instead.
> Using commands to manage subscriptions and there outputs is **deprecated** and will be removed in future releases. Use subscription configuration files instead.
This command exports the currently configured subscriptions in a `json` format. You may export only one subscription using `--subscription <identifier>`.

Expand All @@ -322,7 +322,7 @@ $ openwec subscriptions export
### `openwec subscriptions import` (deprecated)

> [!WARNING]
> Using commands to manage subscriptions and there outputs is **deprecated** and will be removed in future releases. Use subscription configuration files instead.
> Using commands to manage subscriptions and there outputs is **deprecated** and will be removed in future releases. Use subscription configuration files instead.
This command imports subscriptions from a file. Two formats are supported:
* `openwec`: the format generated by `openwec subscriptions export`. **Importing subscriptions exported from another openwec version might not work.**
Expand All @@ -340,7 +340,7 @@ $ openwec subscriptions import -f windows windows-subscription.xml
### `openwec subscriptions delete` (deprecated)

> [!WARNING]
> Using commands to manage subscriptions and there outputs is **deprecated** and will be removed in future releases. Use subscription configuration files instead.
> Using commands to manage subscriptions and there outputs is **deprecated** and will be removed in future releases. Use subscription configuration files instead.
This command deletes subscriptions, and all associated bookmarks and heartbeats. There is no way to undo this action (unless you backup your database, and **you should definitely do it**).

Expand Down Expand Up @@ -375,7 +375,7 @@ $ openwec subscriptions machines my-super-subscription
### `openwec subscriptions enable` (deprecated)

> [!WARNING]
> Using commands to manage subscriptions and there outputs is **deprecated** and will be removed in future releases. Use subscription configuration files instead.
> Using commands to manage subscriptions and there outputs is **deprecated** and will be removed in future releases. Use subscription configuration files instead.
This command enables one or many subscriptions. You may also want to enable all configured subscriptions without listing them using `--all`.

Expand All @@ -394,7 +394,7 @@ $ openwec subscriptions enable my-super-subscription this-is-a-clone
### `openwec subscriptions disable` (deprecated)

> [!WARNING]
> Using commands to manage subscriptions and there outputs is **deprecated** and will be removed in future releases. Use subscription configuration files instead.
> Using commands to manage subscriptions and there outputs is **deprecated** and will be removed in future releases. Use subscription configuration files instead.
This command disables one or many subscriptions. You may also want to disable all configured subscriptions without listing them using `--all`.

Expand Down

0 comments on commit 16305e8

Please sign in to comment.