xsoar-cli 0.0.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of xsoar-cli might be problematic. Click here for more details.

Files changed (91) hide show
  1. xsoar_cli-0.0.3/.github/workflows/release.yml +144 -0
  2. xsoar_cli-0.0.3/.gitignore +8 -0
  3. xsoar_cli-0.0.3/LICENSE.txt +9 -0
  4. xsoar_cli-0.0.3/PKG-INFO +128 -0
  5. xsoar_cli-0.0.3/README.md +103 -0
  6. xsoar_cli-0.0.3/examples/README.md +161 -0
  7. xsoar_cli-0.0.3/examples/advanced_plugin.py +255 -0
  8. xsoar_cli-0.0.3/pyproject.toml +63 -0
  9. xsoar_cli-0.0.3/requirements.txt +4 -0
  10. xsoar_cli-0.0.3/requirements_dev.txt +4 -0
  11. xsoar_cli-0.0.3/src/xsoar_cli/__about__.py +4 -0
  12. xsoar_cli-0.0.3/src/xsoar_cli/__init__.py +1 -0
  13. xsoar_cli-0.0.3/src/xsoar_cli/case/README.md +31 -0
  14. xsoar_cli-0.0.3/src/xsoar_cli/case/__init__.py +0 -0
  15. xsoar_cli-0.0.3/src/xsoar_cli/case/commands.py +86 -0
  16. xsoar_cli-0.0.3/src/xsoar_cli/cli.py +41 -0
  17. xsoar_cli-0.0.3/src/xsoar_cli/config/README.md +12 -0
  18. xsoar_cli-0.0.3/src/xsoar_cli/config/__init__.py +0 -0
  19. xsoar_cli-0.0.3/src/xsoar_cli/config/commands.py +99 -0
  20. xsoar_cli-0.0.3/src/xsoar_cli/graph/README.md +17 -0
  21. xsoar_cli-0.0.3/src/xsoar_cli/graph/__init__.py +0 -0
  22. xsoar_cli-0.0.3/src/xsoar_cli/graph/commands.py +32 -0
  23. xsoar_cli-0.0.3/src/xsoar_cli/manifest/README.md +23 -0
  24. xsoar_cli-0.0.3/src/xsoar_cli/manifest/__init__.py +0 -0
  25. xsoar_cli-0.0.3/src/xsoar_cli/manifest/commands.py +200 -0
  26. xsoar_cli-0.0.3/src/xsoar_cli/pack/README.md +7 -0
  27. xsoar_cli-0.0.3/src/xsoar_cli/pack/__init__.py +0 -0
  28. xsoar_cli-0.0.3/src/xsoar_cli/pack/commands.py +55 -0
  29. xsoar_cli-0.0.3/src/xsoar_cli/playbook/README.md +19 -0
  30. xsoar_cli-0.0.3/src/xsoar_cli/playbook/__init__.py +0 -0
  31. xsoar_cli-0.0.3/src/xsoar_cli/playbook/commands.py +67 -0
  32. xsoar_cli-0.0.3/src/xsoar_cli/plugins/README.md +433 -0
  33. xsoar_cli-0.0.3/src/xsoar_cli/plugins/__init__.py +68 -0
  34. xsoar_cli-0.0.3/src/xsoar_cli/plugins/commands.py +296 -0
  35. xsoar_cli-0.0.3/src/xsoar_cli/plugins/manager.py +399 -0
  36. xsoar_cli-0.0.3/src/xsoar_cli/utilities.py +94 -0
  37. xsoar_cli-0.0.3/tests/__init__.py +3 -0
  38. xsoar_cli-0.0.3/tests/conftest.py +66 -0
  39. xsoar_cli-0.0.3/tests/test_base.py +20 -0
  40. xsoar_cli-0.0.3/tests/test_case.py +37 -0
  41. xsoar_cli-0.0.3/tests/test_config.py +27 -0
  42. xsoar_cli-0.0.3/tests/test_data/Download/playbook-empty.yml +88 -0
  43. xsoar_cli-0.0.3/tests/test_data/Packs/MyOrg_CommonPlaybooks/.pack-ignore +0 -0
  44. xsoar_cli-0.0.3/tests/test_data/Packs/MyOrg_CommonPlaybooks/.secrets-ignore +0 -0
  45. xsoar_cli-0.0.3/tests/test_data/Packs/MyOrg_CommonPlaybooks/Author_image.png +0 -0
  46. xsoar_cli-0.0.3/tests/test_data/Packs/MyOrg_CommonPlaybooks/Playbooks/GenericPlaybook.yml +82 -0
  47. xsoar_cli-0.0.3/tests/test_data/Packs/MyOrg_CommonPlaybooks/README.md +0 -0
  48. xsoar_cli-0.0.3/tests/test_data/Packs/MyOrg_CommonPlaybooks/pack_metadata.json +20 -0
  49. xsoar_cli-0.0.3/tests/test_data/Packs/MyOrg_CommonScripts/.pack-ignore +0 -0
  50. xsoar_cli-0.0.3/tests/test_data/Packs/MyOrg_CommonScripts/.secrets-ignore +0 -0
  51. xsoar_cli-0.0.3/tests/test_data/Packs/MyOrg_CommonScripts/Author_image.png +0 -0
  52. xsoar_cli-0.0.3/tests/test_data/Packs/MyOrg_CommonScripts/README.md +0 -0
  53. xsoar_cli-0.0.3/tests/test_data/Packs/MyOrg_CommonScripts/Scripts/GenericScript/GenericScript.py +79 -0
  54. xsoar_cli-0.0.3/tests/test_data/Packs/MyOrg_CommonScripts/Scripts/GenericScript/GenericScript.yml +29 -0
  55. xsoar_cli-0.0.3/tests/test_data/Packs/MyOrg_CommonScripts/Scripts/GenericScript/README.md +5 -0
  56. xsoar_cli-0.0.3/tests/test_data/Packs/MyOrg_CommonScripts/pack_metadata.json +15 -0
  57. xsoar_cli-0.0.3/tests/test_data/Packs/MyOrg_EDR/.pack-ignore +0 -0
  58. xsoar_cli-0.0.3/tests/test_data/Packs/MyOrg_EDR/.secrets-ignore +0 -0
  59. xsoar_cli-0.0.3/tests/test_data/Packs/MyOrg_EDR/Author_image.png +0 -0
  60. xsoar_cli-0.0.3/tests/test_data/Packs/MyOrg_EDR/Playbooks/EDR_InitialTriage.yml +219 -0
  61. xsoar_cli-0.0.3/tests/test_data/Packs/MyOrg_EDR/README.md +0 -0
  62. xsoar_cli-0.0.3/tests/test_data/Packs/MyOrg_EDR/Scripts/EDR_FetchFile/EDR_FetchFile.py +79 -0
  63. xsoar_cli-0.0.3/tests/test_data/Packs/MyOrg_EDR/Scripts/EDR_FetchFile/EDR_FetchFile.yml +29 -0
  64. xsoar_cli-0.0.3/tests/test_data/Packs/MyOrg_EDR/Scripts/EDR_FetchFile/README.md +5 -0
  65. xsoar_cli-0.0.3/tests/test_data/Packs/MyOrg_EDR/Scripts/EDR_Triage/EDR_Triage.py +79 -0
  66. xsoar_cli-0.0.3/tests/test_data/Packs/MyOrg_EDR/Scripts/EDR_Triage/EDR_Triage.yml +29 -0
  67. xsoar_cli-0.0.3/tests/test_data/Packs/MyOrg_EDR/Scripts/EDR_Triage/README.md +5 -0
  68. xsoar_cli-0.0.3/tests/test_data/Packs/MyOrg_EDR/Scripts/LegacyItem/LegacyItem.py +79 -0
  69. xsoar_cli-0.0.3/tests/test_data/Packs/MyOrg_EDR/Scripts/LegacyItem/LegacyItem.yml +29 -0
  70. xsoar_cli-0.0.3/tests/test_data/Packs/MyOrg_EDR/Scripts/LegacyItem/README.md +5 -0
  71. xsoar_cli-0.0.3/tests/test_data/Packs/MyOrg_EDR/Scripts/LegacyItem/test_data/basescript-dummy.json +0 -0
  72. xsoar_cli-0.0.3/tests/test_data/Packs/MyOrg_EDR/pack_metadata.json +15 -0
  73. xsoar_cli-0.0.3/tests/test_data/Packs/MyOrg_Layouts/.pack-ignore +0 -0
  74. xsoar_cli-0.0.3/tests/test_data/Packs/MyOrg_Layouts/.secrets-ignore +0 -0
  75. xsoar_cli-0.0.3/tests/test_data/Packs/MyOrg_Layouts/Author_image.png +0 -0
  76. xsoar_cli-0.0.3/tests/test_data/Packs/MyOrg_Layouts/Layouts/layoutscontainer-GenericLayout.json +332 -0
  77. xsoar_cli-0.0.3/tests/test_data/Packs/MyOrg_Layouts/README.md +0 -0
  78. xsoar_cli-0.0.3/tests/test_data/Packs/MyOrg_Layouts/pack_metadata.json +15 -0
  79. xsoar_cli-0.0.3/tests/test_data/Packs/Not_applicable/Playbooks/Empty.yml +67 -0
  80. xsoar_cli-0.0.3/tests/test_data/manifest_base.json +15 -0
  81. xsoar_cli-0.0.3/tests/test_data/manifest_invalid.json +15 -0
  82. xsoar_cli-0.0.3/tests/test_data/manifest_with_pack_not_on_server.json +18 -0
  83. xsoar_cli-0.0.3/tests/test_data/server_base_response.json +14 -0
  84. xsoar_cli-0.0.3/tests/test_data/server_base_response_missing_one_pack.json +7 -0
  85. xsoar_cli-0.0.3/tests/test_data/server_base_response_with_updates.json +14 -0
  86. xsoar_cli-0.0.3/tests/test_data/server_base_response_with_updates_and_one_extra.json +20 -0
  87. xsoar_cli-0.0.3/tests/test_graph.py +17 -0
  88. xsoar_cli-0.0.3/tests/test_manifest.py +17 -0
  89. xsoar_cli-0.0.3/tests/test_pack.py +17 -0
  90. xsoar_cli-0.0.3/tests/test_playbook.py +17 -0
  91. xsoar_cli-0.0.3/tests/test_plugins.py +358 -0
@@ -0,0 +1,144 @@
1
+ name: release
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "[0-9]+.[0-9]+.[0-9]+"
7
+ - "[0-9]+.[0-9]+.[0-9]+a[0-9]+"
8
+ - "[0-9]+.[0-9]+.[0-9]+b[0-9]+"
9
+ - "[0-9]+.[0-9]+.[0-9]+rc[0-9]+"
10
+
11
+ env:
12
+ PACKAGE_NAME: "xsoar-cli"
13
+ OWNER: "tlium"
14
+
15
+ jobs:
16
+ details:
17
+ runs-on: ubuntu-latest
18
+ outputs:
19
+ new_version: ${{ steps.release.outputs.new_version }}
20
+ suffix: ${{ steps.release.outputs.suffix }}
21
+ tag_name: ${{ steps.release.outputs.tag_name }}
22
+ steps:
23
+ - uses: actions/checkout@v2
24
+
25
+ - name: Extract tag and Details
26
+ id: release
27
+ run: |
28
+ if [ "${{ github.ref_type }}" = "tag" ]; then
29
+ TAG_NAME=${GITHUB_REF#refs/tags/}
30
+ NEW_VERSION=$(echo $TAG_NAME | awk -F'-' '{print $1}')
31
+ SUFFIX=$(echo $TAG_NAME | grep -oP '[a-z]+[0-9]+' || echo "")
32
+ echo "new_version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
33
+ echo "suffix=$SUFFIX" >> "$GITHUB_OUTPUT"
34
+ echo "tag_name=$TAG_NAME" >> "$GITHUB_OUTPUT"
35
+ echo "Version is $NEW_VERSION"
36
+ echo "Suffix is $SUFFIX"
37
+ echo "Tag name is $TAG_NAME"
38
+ else
39
+ echo "No tag found"
40
+ exit 1
41
+ fi
42
+
43
+ check_pypi:
44
+ needs: details
45
+ runs-on: ubuntu-latest
46
+ steps:
47
+ - name: Fetch information from PyPI
48
+ run: |
49
+ response=$(curl -s https://pypi.org/pypi/${{ env.PACKAGE_NAME }}/json || echo "{}")
50
+ latest_previous_version=$(echo $response | jq --raw-output "select(.releases != null) | .releases | keys_unsorted | last")
51
+ if [ -z "$latest_previous_version" ]; then
52
+ echo "Package not found on PyPI."
53
+ latest_previous_version="0.0.0"
54
+ fi
55
+ echo "Latest version on PyPI: $latest_previous_version"
56
+ echo "latest_previous_version=$latest_previous_version" >> $GITHUB_ENV
57
+
58
+ - name: Compare versions and exit if not newer
59
+ run: |
60
+ NEW_VERSION=${{ needs.details.outputs.new_version }}
61
+ LATEST_VERSION=$latest_previous_version
62
+ if [ "$(printf '%s\n' "$LATEST_VERSION" "$NEW_VERSION" | sort -rV | head -n 1)" != "$NEW_VERSION" ] || [ "$NEW_VERSION" == "$LATEST_VERSION" ]; then
63
+ echo "The new version $NEW_VERSION is not greater than the latest version $LATEST_VERSION on PyPI."
64
+ exit 1
65
+ else
66
+ echo "The new version $NEW_VERSION is greater than the latest version $LATEST_VERSION on PyPI."
67
+ fi
68
+
69
+ setup_and_build:
70
+ needs: [details, check_pypi]
71
+ runs-on: ubuntu-latest
72
+ steps:
73
+ - uses: actions/checkout@v2
74
+
75
+ - name: Set up Python
76
+ uses: actions/setup-python@v4
77
+ with:
78
+ python-version: "3.12"
79
+ cache: "pip"
80
+
81
+ - name: Install Hatch
82
+ run: |
83
+ python -m pip install --upgrade pip
84
+ pip install hatch
85
+
86
+ - name: Set project version with Hatch
87
+ run: |
88
+ hatch version ${{ needs.details.outputs.new_version }}
89
+
90
+ - name: Install dependencies
91
+ run: pip install -r requirements.txt
92
+
93
+ - name: Build source and wheel distribution
94
+ run: |
95
+ hatch build
96
+
97
+ - name: Upload artifacts
98
+ uses: actions/upload-artifact@v4
99
+ with:
100
+ name: dist
101
+ path: dist/
102
+
103
+ pypi_publish:
104
+ name: Upload release to PyPI
105
+ needs: [setup_and_build, details]
106
+ runs-on: ubuntu-latest
107
+ environment:
108
+ name: release
109
+ permissions:
110
+ id-token: write
111
+ steps:
112
+ - name: Download artifacts
113
+ uses: actions/download-artifact@v4
114
+ with:
115
+ name: dist
116
+ path: dist/
117
+
118
+ - name: Publish distribution to PyPI
119
+ uses: pypa/gh-action-pypi-publish@release/v1
120
+
121
+ github_release:
122
+ name: Create GitHub Release
123
+ needs: [setup_and_build, details]
124
+ runs-on: ubuntu-latest
125
+ permissions:
126
+ contents: write
127
+ steps:
128
+ - name: Checkout Code
129
+ uses: actions/checkout@v3
130
+ with:
131
+ fetch-depth: 0
132
+
133
+ - name: Download artifacts
134
+ uses: actions/download-artifact@v4
135
+ with:
136
+ name: dist
137
+ path: dist/
138
+
139
+ - name: Create GitHub Release
140
+ id: create_release
141
+ env:
142
+ GH_TOKEN: ${{ github.token }}
143
+ run: |
144
+ gh release create ${{ needs.details.outputs.tag_name }} dist/* --title ${{ needs.details.outputs.tag_name }} --generate-notes
@@ -0,0 +1,8 @@
1
+ **/__pycache__
2
+ dist
3
+ build
4
+ venv
5
+ xsoar_config.json
6
+ .venv
7
+ .coverage
8
+ .pytest_cache
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025-present Torbjørn Lium <torben@lium.org>
4
+
5
+ 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:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ 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 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,128 @@
1
+ Metadata-Version: 2.4
2
+ Name: xsoar-cli
3
+ Version: 0.0.3
4
+ Project-URL: Documentation, https://github.com/tlium/xsoar-cli#readme
5
+ Project-URL: Issues, https://github.com/tliumb/xsoar-cli/issues
6
+ Project-URL: Source, https://github.com/tlium/xsoar-cli
7
+ Author-email: Torbjørn Lium <torben@lium.org>
8
+ License-Expression: MIT
9
+ License-File: LICENSE.txt
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Programming Language :: Python
12
+ Classifier: Programming Language :: Python :: 3.8
13
+ Classifier: Programming Language :: Python :: 3.9
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: Implementation :: CPython
18
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
19
+ Requires-Python: >=3.8
20
+ Requires-Dist: click==8.1.8
21
+ Requires-Dist: pyyaml>=6.0.2
22
+ Requires-Dist: xsoar-client>=1.0.0
23
+ Requires-Dist: xsoar-dependency-graph>=0.0.3
24
+ Description-Content-Type: text/markdown
25
+
26
+ # xsoar-cli
27
+ -----
28
+ This tool is made to help provide a smoother workflow for developers, but also for power users to get useful information out of XSOAR from
29
+ the terminal. Merge requests are very welcome and appreciated!
30
+
31
+ *IMPORTANT NOTE* This CLI tools is made to be run from the root of a content repository. Some commands depends on files located in your
32
+ content repository or expects a certain directory structure to be available from your currently working directory.
33
+
34
+ ## Installation
35
+ ```
36
+ pip install xsoar-cli
37
+ ```
38
+ ## Upgrading
39
+ ```
40
+ pip install --upgrade xsoar-cli
41
+ ```
42
+
43
+
44
+ ## Configuration
45
+ The xsoar-cli config file is located in `~/.config/xsoar-cli/config.json`. To create a configuration file from template, please run
46
+ ```
47
+ xsoar-cli config create
48
+ ```
49
+ Open up the newly created configuration file and add values that correspond with your environment.
50
+ *IMPORTANT NOTE*: the configuration key `"custom_pack_authors": ["SOMEONE"]` is needed in order for `xsoar-cli` to be able to
51
+ determine which content packs are your own custom content packs and which are supplied from Palo Alto upstream. Use whateve values you may have set in
52
+ pack_metadata.json in the content packs in your content repository.
53
+
54
+ ## Usage
55
+ ```
56
+ xsoar-cli <command> <sub-command> <args>
57
+ ```
58
+ For information about available commands, run `xsoar-cli` without arguments.
59
+
60
+ For more information on a specific command execute `xsoar-cli <command> --help.`
61
+
62
+ ### Commands
63
+ 1. [case](src/xsoar_cli/case/README.md)
64
+ 2. [config](src/xsoar_cli/config/README.md)
65
+ 3. [manifest](src/xsoar_cli/manifest/README.md)
66
+ 4. [pack](src/xsoar_cli/pack/README.md)
67
+ 5. [playbook](src/xsoar_cli/playbook/README.md)
68
+ 6. [plugins](src/xsoar_cli/plugins/README.md)
69
+
70
+ ## Plugin System
71
+
72
+ xsoar-cli supports a plugin system that allows you to extend the CLI with custom commands. Plugins are Python files that you place in `~/.local/xsoar-cli/plugins/` and they're automatically discovered and loaded.
73
+
74
+ ### Quick Start with Plugins
75
+
76
+ 1. **Create an example plugin**:
77
+ ```bash
78
+ xsoar-cli plugins create-example
79
+ ```
80
+
81
+ 2. **List available plugins**:
82
+ ```bash
83
+ xsoar-cli plugins list
84
+ ```
85
+
86
+ 3. **Test the example plugin**:
87
+ ```bash
88
+ xsoar-cli example hello --name "World"
89
+ ```
90
+
91
+ ### Plugin Management Commands
92
+
93
+ - `xsoar-cli plugins list` - List all plugins
94
+ - `xsoar-cli plugins info <plugin>` - Show plugin information
95
+ - `xsoar-cli plugins validate` - Validate all plugins
96
+ - `xsoar-cli plugins reload <plugin>` - Reload a specific plugin
97
+ - `xsoar-cli plugins create-example` - Create an example plugin
98
+ - `xsoar-cli plugins open` - Open the plugins directory
99
+
100
+ ### Creating Your Own Plugins
101
+
102
+ Create a Python file in `~/.local/xsoar-cli/plugins/` that inherits from `XSOARPlugin`:
103
+
104
+ ```python
105
+ import click
106
+ from xsoar_cli.plugins import XSOARPlugin
107
+
108
+ class MyPlugin(XSOARPlugin):
109
+ @property
110
+ def name(self) -> str:
111
+ return "myplugin"
112
+
113
+ @property
114
+ def version(self) -> str:
115
+ return "1.0.0"
116
+
117
+ def get_command(self) -> click.Command:
118
+ @click.command(help="My custom command")
119
+ def mycommand():
120
+ click.echo("Hello from my plugin!")
121
+ return mycommand
122
+ ```
123
+
124
+ For detailed documentation, see [Plugin System Documentation](src/xsoar_cli/plugins/README.md).
125
+
126
+ ## License
127
+
128
+ `xsoar-cli` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.
@@ -0,0 +1,103 @@
1
+ # xsoar-cli
2
+ -----
3
+ This tool is made to help provide a smoother workflow for developers, but also for power users to get useful information out of XSOAR from
4
+ the terminal. Merge requests are very welcome and appreciated!
5
+
6
+ *IMPORTANT NOTE* This CLI tools is made to be run from the root of a content repository. Some commands depends on files located in your
7
+ content repository or expects a certain directory structure to be available from your currently working directory.
8
+
9
+ ## Installation
10
+ ```
11
+ pip install xsoar-cli
12
+ ```
13
+ ## Upgrading
14
+ ```
15
+ pip install --upgrade xsoar-cli
16
+ ```
17
+
18
+
19
+ ## Configuration
20
+ The xsoar-cli config file is located in `~/.config/xsoar-cli/config.json`. To create a configuration file from template, please run
21
+ ```
22
+ xsoar-cli config create
23
+ ```
24
+ Open up the newly created configuration file and add values that correspond with your environment.
25
+ *IMPORTANT NOTE*: the configuration key `"custom_pack_authors": ["SOMEONE"]` is needed in order for `xsoar-cli` to be able to
26
+ determine which content packs are your own custom content packs and which are supplied from Palo Alto upstream. Use whateve values you may have set in
27
+ pack_metadata.json in the content packs in your content repository.
28
+
29
+ ## Usage
30
+ ```
31
+ xsoar-cli <command> <sub-command> <args>
32
+ ```
33
+ For information about available commands, run `xsoar-cli` without arguments.
34
+
35
+ For more information on a specific command execute `xsoar-cli <command> --help.`
36
+
37
+ ### Commands
38
+ 1. [case](src/xsoar_cli/case/README.md)
39
+ 2. [config](src/xsoar_cli/config/README.md)
40
+ 3. [manifest](src/xsoar_cli/manifest/README.md)
41
+ 4. [pack](src/xsoar_cli/pack/README.md)
42
+ 5. [playbook](src/xsoar_cli/playbook/README.md)
43
+ 6. [plugins](src/xsoar_cli/plugins/README.md)
44
+
45
+ ## Plugin System
46
+
47
+ xsoar-cli supports a plugin system that allows you to extend the CLI with custom commands. Plugins are Python files that you place in `~/.local/xsoar-cli/plugins/` and they're automatically discovered and loaded.
48
+
49
+ ### Quick Start with Plugins
50
+
51
+ 1. **Create an example plugin**:
52
+ ```bash
53
+ xsoar-cli plugins create-example
54
+ ```
55
+
56
+ 2. **List available plugins**:
57
+ ```bash
58
+ xsoar-cli plugins list
59
+ ```
60
+
61
+ 3. **Test the example plugin**:
62
+ ```bash
63
+ xsoar-cli example hello --name "World"
64
+ ```
65
+
66
+ ### Plugin Management Commands
67
+
68
+ - `xsoar-cli plugins list` - List all plugins
69
+ - `xsoar-cli plugins info <plugin>` - Show plugin information
70
+ - `xsoar-cli plugins validate` - Validate all plugins
71
+ - `xsoar-cli plugins reload <plugin>` - Reload a specific plugin
72
+ - `xsoar-cli plugins create-example` - Create an example plugin
73
+ - `xsoar-cli plugins open` - Open the plugins directory
74
+
75
+ ### Creating Your Own Plugins
76
+
77
+ Create a Python file in `~/.local/xsoar-cli/plugins/` that inherits from `XSOARPlugin`:
78
+
79
+ ```python
80
+ import click
81
+ from xsoar_cli.plugins import XSOARPlugin
82
+
83
+ class MyPlugin(XSOARPlugin):
84
+ @property
85
+ def name(self) -> str:
86
+ return "myplugin"
87
+
88
+ @property
89
+ def version(self) -> str:
90
+ return "1.0.0"
91
+
92
+ def get_command(self) -> click.Command:
93
+ @click.command(help="My custom command")
94
+ def mycommand():
95
+ click.echo("Hello from my plugin!")
96
+ return mycommand
97
+ ```
98
+
99
+ For detailed documentation, see [Plugin System Documentation](src/xsoar_cli/plugins/README.md).
100
+
101
+ ## License
102
+
103
+ `xsoar-cli` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.
@@ -0,0 +1,161 @@
1
+ # XSOAR CLI Plugin Examples
2
+
3
+ This directory contains example plugins that demonstrate various features and capabilities of the XSOAR CLI plugin system.
4
+
5
+ ## Examples
6
+
7
+ ### advanced_plugin.py
8
+
9
+ A comprehensive example plugin that demonstrates:
10
+
11
+ - **Multiple command groups** - Organized commands into logical groups (`cases`, `utils`)
12
+ - **XSOAR integration patterns** - Shows how to structure commands that would interact with XSOAR
13
+ - **Rich CLI features** - Options, arguments, validation, prompts, confirmations
14
+ - **File operations** - Reading/writing files, log analysis
15
+ - **Error handling** - Proper exception handling and user feedback
16
+ - **Code generation** - Dynamic template generation for new plugins
17
+
18
+ #### Usage
19
+
20
+ 1. Copy the file to your plugins directory:
21
+ ```bash
22
+ cp examples/advanced_plugin.py ~/.local/xsoar-cli/plugins/
23
+ ```
24
+
25
+ 2. Verify the plugin is loaded:
26
+ ```bash
27
+ xsoar-cli plugins list
28
+ ```
29
+
30
+ 3. Use the plugin commands:
31
+ ```bash
32
+ # List cases
33
+ xsoar-cli advanced cases list --limit 5
34
+
35
+ # Create a test case
36
+ xsoar-cli advanced cases create --name "Test Case" --severity High
37
+
38
+ # Analyze a log file
39
+ xsoar-cli advanced utils analyze-log /path/to/logfile.log --pattern "error"
40
+
41
+ # Generate a new plugin template
42
+ xsoar-cli advanced utils generate-template MyCustomPlugin
43
+
44
+ # Show plugin statistics
45
+ xsoar-cli advanced stats --verbose
46
+ ```
47
+
48
+ ## Creating Your Own Plugins
49
+
50
+ ### Quick Start
51
+
52
+ 1. **Use the built-in example generator**:
53
+ ```bash
54
+ xsoar-cli plugins create-example
55
+ ```
56
+
57
+ 2. **Or generate a custom template**:
58
+ ```bash
59
+ xsoar-cli advanced utils generate-template YourPluginName
60
+ ```
61
+
62
+ 3. **Copy to plugins directory**:
63
+ ```bash
64
+ cp YourPluginName_plugin.py ~/.local/xsoar-cli/plugins/
65
+ ```
66
+
67
+ ### Plugin Structure
68
+
69
+ Every plugin must inherit from `XSOARPlugin` and implement these required methods:
70
+
71
+ ```python
72
+ import click
73
+
74
+ class MyPlugin(XSOARPlugin):
75
+ @property
76
+ def name(self) -> str:
77
+ return "myplugin"
78
+
79
+ @property
80
+ def version(self) -> str:
81
+ return "1.0.0"
82
+
83
+ @property
84
+ def description(self) -> str:
85
+ return "My custom plugin"
86
+
87
+ def get_command(self) -> click.Command:
88
+ @click.command(help="My command")
89
+ def mycommand():
90
+ click.echo("Hello from my plugin!")
91
+ return mycommand
92
+ ```
93
+
94
+ ### Best Practices
95
+
96
+ 1. **Use descriptive names** - Choose clear, unique command names
97
+ 2. **Organize with groups** - Use `@click.group()` for multiple related commands
98
+ 3. **Handle errors gracefully** - Use try/catch and proper error messages
99
+ 4. **Validate inputs** - Use Click's built-in validation options
100
+ 5. **Provide helpful output** - Use colors, formatting, and clear messages
101
+ 6. **Document your commands** - Add help text and descriptions
102
+
103
+ ### XSOAR Integration
104
+
105
+ To integrate with XSOAR in your plugins, use the configuration system:
106
+
107
+ ```python
108
+ from xsoar_cli.utilities import load_config
109
+
110
+ @click.command()
111
+ @click.pass_context
112
+ @load_config
113
+ def my_xsoar_command(ctx: click.Context):
114
+ # Access XSOAR client
115
+ xsoar_client = ctx.obj["server_envs"]["dev"]
116
+
117
+ # Use the client for XSOAR operations
118
+ cases = xsoar_client.get_cases()
119
+ # ... your logic here
120
+ ```
121
+
122
+ ## Testing Your Plugins
123
+
124
+ 1. **Validate syntax**:
125
+ ```bash
126
+ xsoar-cli plugins validate
127
+ ```
128
+
129
+ 2. **Check plugin info**:
130
+ ```bash
131
+ xsoar-cli plugins info your_plugin_name
132
+ ```
133
+
134
+ 3. **Test commands**:
135
+ ```bash
136
+ xsoar-cli your-command --help
137
+ xsoar-cli your-command test-args
138
+ ```
139
+
140
+ 4. **Reload during development**:
141
+ ```bash
142
+ xsoar-cli plugins reload your_plugin_name
143
+ ```
144
+
145
+ ## Sharing Plugins
146
+
147
+ To share your plugins with others:
148
+
149
+ 1. **Simple sharing** - Share the `.py` file directly
150
+ 2. **Documentation** - Include usage examples and requirements
151
+ 3. **Dependencies** - List any external packages needed
152
+ 4. **Testing** - Provide test cases or examples
153
+
154
+ ## Getting Help
155
+
156
+ - **Plugin documentation**: `src/xsoar_cli/plugins/README.md`
157
+ - **List available plugins**: `xsoar-cli plugins list`
158
+ - **Plugin commands help**: `xsoar-cli plugins --help`
159
+ - **Command-specific help**: `xsoar-cli <plugin-command> --help`
160
+
161
+ Happy plugin development! 🚀