Skip to content
This repository has been archived by the owner on Dec 30, 2023. It is now read-only.

Commit

Permalink
patch version with updated dependencies, added some docstrings and up…
Browse files Browse the repository at this point in the history
…dated pre-commit tool versions
  • Loading branch information
n0mer1 committed Apr 23, 2022
1 parent 26b1d89 commit cc6b9ad
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 64 deletions.
4 changes: 1 addition & 3 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@
},
"remoteUser": "codespace",
"overrideCommand": false,
"mounts": [
"source=codespaces-linux-var-lib-docker,target=/var/lib/docker,type=volume"
],
"mounts": ["source=codespaces-linux-var-lib-docker,target=/var/lib/docker,type=volume"],
"runArgs": [
"--cap-add=SYS_PTRACE",
"--security-opt",
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8]
python-version: [3.7, 3.8, 3.9]
fail-fast: false

steps:
Expand All @@ -22,8 +22,8 @@ jobs:
- name: Get full python version
id: full-python-version
run:
echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v)
for v in sys.version_info))")
echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in
sys.version_info))")
- name: Install poetry
run: |
curl -fsS -o get-poetry.py https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py
Expand Down
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
repos:
# Common stuff and checks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
rev: v4.2.0
hooks:
- id: check-added-large-files
args: [--maxkb=800]
Expand Down Expand Up @@ -44,14 +44,14 @@ repos:
args: [--settings-file, pyproject.toml]

- repo: https://github.com/psf/black
rev: 21.12b0
rev: 22.3.0
hooks:
- id: black
language_version: python3
args: ["--line-length=100"]

- repo: https://github.com/asottile/blacken-docs
rev: v1.11.0
rev: v1.12.1
hooks:
- id: blacken-docs
additional_dependencies: [black==21.12b0]
Expand All @@ -65,7 +65,7 @@ repos:
args: ["--keep-output", "--extra-keys", "metadata.kernelspec"]

- repo: https://github.com/myint/rstcheck
rev: master # "3f92957478422df87bd730abde66f089cc1ee19b"
rev: v5.0.0 # "3f92957478422df87bd730abde66f089cc1ee19b"
hooks:
- id: rstcheck
args:
Expand All @@ -77,7 +77,7 @@ repos:
files: ^(ChangeLog|doc/(.*/)*.*\.rst)

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.5.1
rev: v2.6.2
hooks:
- id: prettier
args: [--prose-wrap=always, --print-width=88]
args: [--prose-wrap=always, --print-width=100]
68 changes: 31 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,16 @@
</br>
</div>

This library is an abstraction for Splunk-related development, maintenance, or migration
operations. It provides a single CLI or SDK to conveniently perform various operations
such as managing a local development container, retrieving sample-data, building
applications, comparing instances, managing knowledge objects and hopefully much more in
the future.
This library is an abstraction for Splunk-related development, maintenance, or migration operations.
It provides a single CLI or SDK to conveniently perform various operations such as managing a local
development container, retrieving sample-data, building applications, comparing instances, managing
knowledge objects and hopefully much more in the future.

## Motivation 🔥

When I work with Splunk, my working directory is usually in the same layout. I work with
a mono-repository or a higher-level one with submodules, which contains several
applications and configuration. This can look generalized like this:
When I work with Splunk, my working directory is usually in the same layout. I work with a
mono-repository or a higher-level one with submodules, which contains several applications and
configuration. This can look generalized like this:

```
<Development Repository>
Expand All @@ -35,13 +34,12 @@ applications and configuration. This can look generalized like this:
└── share # Custom splunkbase or builtin app content
```

We have all found our ways and methods to develop applications on an instance and to
configure and operate that instance to meet our needs and/or those of our customers. But
what is usually rather painful is when we then need them on other instances as well. A
good example are test instances, which should be as close to production as possible.
However, in the last few years that I have been dealing as a user with Splunk, some
needs for simplified handling and automation have emerged that I would like to address
here.
We have all found our ways and methods to develop applications on an instance and to configure and
operate that instance to meet our needs and/or those of our customers. But what is usually rather
painful is when we then need them on other instances as well. A good example are test instances,
which should be as close to production as possible. However, in the last few years that I have been
dealing as a user with Splunk, some needs for simplified handling and automation have emerged that I
would like to address here.

### We want to ...

Expand Down Expand Up @@ -98,28 +96,25 @@ and probably much more, so pull requests are welcome!

## Getting Started 🚀

You can download the package from the package feed via `pip install spl-manager` or
install from source with [poetry](https://python-poetry.org/) after cloning the
repository.
You can download the package from the package feed via `pip install spl-manager` or install from
source with [poetry](https://python-poetry.org/) after cloning the repository.

Then you can issue your first command to get the help page:

```bash
python -m spl -h
```

or `poetry run python -m spl -h`. Anyhow it's recommended to set the
`alias spl="python -m spl` for easier handling.
or `poetry run python -m spl -h`. Anyhow it's recommended to set the `alias spl="python -m spl` for
easier handling.

You have to create a `config\.secrets.yaml` file by using the
`config\template.secrets.yaml` file, which contains the credentials for the Development
Docker-Container and Splunkbase.
You have to create a `config\.secrets.yaml` file by using the `config\template.secrets.yaml` file,
which contains the credentials for the Development Docker-Container and Splunkbase.

## Using the library 📚

Please note that, when using the library as an SDK you need to pass the
`interactive=False` flag to not run into issues because in _interactive_ mode it asks
for user inputs via CLI methods.
Please note that, when using the library as an SDK you need to pass the `interactive=False` flag to
not run into issues because in _interactive_ mode it asks for user inputs via CLI methods.

```python
from spl import SplManager
Expand All @@ -129,8 +124,7 @@ spl = SplManager(interactive=False)

## Using the CLI 🧑‍💻

If you wish to get more information about any command within `spl`, you can pass the
`-h` parameter.
If you wish to get more information about any command within `spl`, you can pass the `-h` parameter.

### Top-level `spl` Options

Expand All @@ -144,17 +138,16 @@ If you wish to get more information about any command within `spl`, you can pass

- `docker` helps you to manage the local splunk container instance.

- `apps` abstracts the handling of local application folders at a given `--path` and
helps with validation, packaging, vetting, etc.
- `apps` abstracts the handling of local application folders at a given `--path` and helps with
validation, packaging, vetting, etc.

- `samples` are based on the configured queries for a `--conn` or `--src` and can
download results and store them automatically at a `--path` to use for _SA-Eventgen_.
- `samples` are based on the configured queries for a `--conn` or `--src` and can download results
and store them automatically at a `--path` to use for _SA-Eventgen_.

- `manager` acts as a direct `ConnectionAdapter` interface for the specified `--conn`
parameter.
- `manager` acts as a direct `ConnectionAdapter` interface for the specified `--conn` parameter.

- `sync` will handle `manager`s for `--src` and `--dest` connections, enabling you to
compare, move and update between those instances.
- `sync` will handle `manager`s for `--src` and `--dest` connections, enabling you to compare, move
and update between those instances.

## 🔗 References

Expand All @@ -171,7 +164,8 @@ If you wish to get more information about any command within `spl`, you can pass

## 🤩 Support

[![Support via PayPal](https://img.shields.io/badge/PayPal-00457C?style=for-the-badge&logo=paypal&logoColor=white)](https://www.paypal.com/donate/?hosted_button_id=UXNY3UEYKBJ7L) or send us some crypto:
[![Support via PayPal](https://img.shields.io/badge/PayPal-00457C?style=for-the-badge&logo=paypal&logoColor=white)](https://www.paypal.com/donate/?hosted_button_id=UXNY3UEYKBJ7L)
or send us some crypto:

| Protocol | Address |
| ------------------- | ----------------------------------------------- |
Expand Down
3 changes: 1 addition & 2 deletions config/settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ default:
SPLUNK_PASSWORD: mySplunkDevPw
SPLUNK_CMD_1: "restart"
PATH: $PATH:/opt/splunk/bin
SPLUNK_CMD:
"add licenses -auth admin:${SPLUNK_PASSWORD} /hack/splunk/licenses/*.lic || true"
SPLUNK_CMD: "add licenses -auth admin:${SPLUNK_PASSWORD} /hack/splunk/licenses/*.lic || true"
apps:
exclude:
- 075-cloudworks
Expand Down
20 changes: 9 additions & 11 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
## Welcome to GitHub Pages

You can use the
[editor on GitHub](https://github.com/nextpart/spl-manager/edit/main/docs/index.md) to
maintain and preview the content for your website in Markdown files.
You can use the [editor on GitHub](https://github.com/nextpart/spl-manager/edit/main/docs/index.md)
to maintain and preview the content for your website in Markdown files.

Whenever you commit to this repository, GitHub Pages will run
[Jekyll](https://jekyllrb.com/) to rebuild the pages in your site, from the content in
your Markdown files.
Whenever you commit to this repository, GitHub Pages will run [Jekyll](https://jekyllrb.com/) to
rebuild the pages in your site, from the content in your Markdown files.

### Markdown

Markdown is a lightweight and easy-to-use syntax for styling your writing. It includes
conventions for
Markdown is a lightweight and easy-to-use syntax for styling your writing. It includes conventions
for

```markdown
Syntax highlighted code block
Expand All @@ -38,9 +36,9 @@ For more details see

### Jekyll Themes

Your Pages site will use the layout and styles from the Jekyll theme you have selected
in your [repository settings](https://github.com/nextpart/spl-manager/settings/pages).
The name of this theme is saved in the Jekyll `_config.yml` configuration file.
Your Pages site will use the layout and styles from the Jekyll theme you have selected in your
[repository settings](https://github.com/nextpart/spl-manager/settings/pages). The name of this
theme is saved in the Jekyll `_config.yml` configuration file.

### Support or Contact

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ authors = ["Nextpart Security Intelligence <info@nextpart.io>"]
description = "A helper for Splunk-related development, maintenance, or migration operations."
name = "spl-manager"
readme = 'README.md'
version = "0.1.1"
version = "0.1.2"

[tool.poetry.scripts]
spl = 'spl_manager.__main__:main'
Expand Down
1 change: 1 addition & 0 deletions spl_manager/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ def apps(self, path: Union[Path, str] = Path.cwd(), name: str = "None") -> AppsM


def main():
"""Default execution CLI interface."""
try:
fire.Fire(name="spl", component=SplManager)
except KeyboardInterrupt:
Expand Down
2 changes: 1 addition & 1 deletion spl_manager/sync_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def confs(
delete: bool = False,
simulate: bool = False,
):

"""Synchronize generic configuration objects."""
print(f"{conf=}")

for stanza in self.src.client.confs[conf].list():
Expand Down

0 comments on commit cc6b9ad

Please sign in to comment.