Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: proxy component #1444

Open
wants to merge 44 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
0ecabba
feat: add proxy tab changes
hetangmodi-crest Oct 14, 2024
21ed369
feat: added `need-proxy` in init function
hetangmodi-crest Nov 11, 2024
e8ce59b
tests(unit): updated test case for init method
hetangmodi-crest Nov 11, 2024
27ebf4b
docs: updated the docs for `--need-proxy` argument
hetangmodi-crest Nov 11, 2024
2bea8f8
feat: added proxy component
hetangmodi-crest Nov 11, 2024
273a7ed
tests: added test cases for proxy component
hetangmodi-crest Nov 11, 2024
699f99c
feat: updated the fetching of proxy
hetangmodi-crest Nov 11, 2024
c002258
tests(smoke): updated the test cases
hetangmodi-crest Nov 11, 2024
ceb3182
Merge branch 'develop' into feat/proxy-component
hetangmodi-crest Nov 12, 2024
686a744
Merge branch 'develop' into feat/proxy-component
hetangmodi-crest Nov 13, 2024
395a562
docs: updated documentation regarding proxy tab
hetangmodi-crest Nov 13, 2024
5eb8e36
ci: fixed pre-commit failures
hetangmodi-crest Nov 13, 2024
ef6eea6
tests: updated unit test case
hetangmodi-crest Nov 13, 2024
f907e61
tests(smoke): added proxyTab in global_config_update
hetangmodi-crest Nov 13, 2024
26bf7fa
fix: fix for UI test cases
hetangmodi-crest Nov 14, 2024
607ab26
fix: skips the migration on proxy tab
hetangmodi-crest Nov 14, 2024
95c680d
Merge branch 'develop' into feat/proxy-component
hetangmodi-crest Nov 15, 2024
81a9a7d
chore: changed label of DNS resolution
hetangmodi-crest Nov 15, 2024
e89efa4
Merge branch 'develop' into feat/proxy-component
hetangmodi-crest Nov 18, 2024
d85c82a
Merge branch 'develop' into feat/proxy-component
hetangmodi-crest Nov 19, 2024
465f71c
fix: pre-commit fix in docs
hetangmodi-crest Nov 19, 2024
310f7a4
Merge branch 'develop' into feat/proxy-component
hetangmodi-crest Nov 21, 2024
0b6d30e
docs: simplified the documentation
hetangmodi-crest Nov 21, 2024
8956d97
feat: checks `sonlib` version if oauth is present
hetangmodi-crest Nov 21, 2024
134ca45
tests(unit): add unit test case
hetangmodi-crest Nov 21, 2024
02f0e9c
chore: merge branch 'develop' into feat/proxy-component
hetangmodi-crest Nov 26, 2024
d769db8
Merge branch 'develop' into feat/proxy-component
hetangmodi-crest Nov 27, 2024
62fc83e
chore: update log statements
hetangmodi-crest Nov 28, 2024
3a5708b
Merge branch 'develop' into feat/proxy-component
hetangmodi-crest Nov 28, 2024
219bf5e
Merge branch 'develop' into feat/proxy-component
artemrys Nov 28, 2024
a2d9c80
chore: update templates and schema.json
hetangmodi-crest Nov 29, 2024
5aedea1
fix: update schema.json
hetangmodi-crest Dec 2, 2024
7056156
chore: merge branch 'develop' into feat/proxy-component
hetangmodi-crest Dec 3, 2024
a8aabd6
chore: resolve code review comments
hetangmodi-crest Dec 3, 2024
0758319
test(unit): update unit test case after rebasing
hetangmodi-crest Dec 3, 2024
10a778e
fix: remove restHandlers from schema for proxy
hetangmodi-crest Dec 10, 2024
b703f03
Merge branch 'develop' into feat/proxy-component
hetangmodi-crest Dec 10, 2024
2d6ac73
Merge branch 'develop' into feat/proxy-component
hetangmodi-crest Dec 12, 2024
d2bfe29
Merge branch 'develop' into feat/proxy-component
hetangmodi-crest Dec 13, 2024
cb55b05
docs: update proxy documentation
hetangmodi-crest Dec 13, 2024
e230928
Merge branch 'develop' into feat/proxy-component
hetangmodi-crest Dec 16, 2024
ad2c7c3
docs: update the proxy doc
hetangmodi-crest Dec 18, 2024
74940e2
chore: merge branch 'develop' into feat/proxy-component
hetangmodi-crest Jan 6, 2025
ac16833
chore: update license header
hetangmodi-crest Jan 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ site/
assets/
Splunk_TA_Dynatrace/*
Splunk_TA_Dynatrace_ucc/*
demo_addon_for_splunk_already_exists/
demo_addon_for_splunk_license/
addon_name
demo_addon_for_splunk*/
addon_name/
init_addon_for_ucc_package/
demo_addon_for_splunk/

Expand Down
23 changes: 14 additions & 9 deletions docs/configurations/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ tab.
Currently available tab components:

- [Logging tab](./logging.md)
- [Proxy tab](./proxy.md)

### Usage

Expand All @@ -56,12 +57,16 @@ Currently available tab components:
"entity": []
},
{
"name": "proxy",
"title": "Proxy",
"entity": [],
"options": {
"saveValidator": ""
}
"type": "proxyTab",
"warning": {
"config": {
"message": "Some warning message"
}
},
"proxy_type": true,
"username": true,
"password": true,
artemrys marked this conversation as resolved.
Show resolved Hide resolved
"dns_resolution": true
},
{
"type": "loggingTab"
Expand All @@ -70,7 +75,7 @@ Currently available tab components:
}
```

Note: The example above creates a Configuration page with two **empty** tabs: Account and Proxy.
Note: The example above creates a Configuration page with an **empty** Account tab.
Specify your properties in `"table"` and `"entity"`.

### Output
Expand All @@ -79,8 +84,8 @@ This is how table looks in the UI:

![image](../images/configuration/configuration_with_table_output.png)

This is how form looks in the UI:
This is how Proxy tab looks in the UI:

![image](../images/configuration/configuration_without_table_output.png)
![image](../images/configuration/proxy_tab_with_warning.png)

More information about how to set Proxy tab, can be found [here](./proxy.md).
309 changes: 210 additions & 99 deletions docs/configurations/proxy.md
Original file line number Diff line number Diff line change
@@ -1,120 +1,231 @@
# Proxy
sgoral-splunk marked this conversation as resolved.
Show resolved Hide resolved

There are fields that need to be specified in order to enable proxy.
The Proxy tab is a predefined component that allows to create a proxy tab with default configurations. It is added in the `pages.configuration.tabs` array

### Fields
![image](../images/configuration/proxy_tab.png)

| Field Name | Description |
|----------------|--------------------------------------------------------------------|
| proxy_enabled | Whether proxy should be enabled. |
| proxy_type | Proxy type. Available values: http, http_no_tunnel, socks4, socks5 |
| proxy_url | Host |
| proxy_port | Port |
| proxy_username | Username used to access the proxy server |
| proxy_password | Password assigned for that username |
| proxy_rdns | Whether reverse DNS resolution should be used |

### Example Tab
### Minimal definition

```json
{
"name": "proxy",
"title": "Proxy",
"entity": [
{
"type": "checkbox",
"label": "Enable",
"field": "proxy_enabled"
},
{
"type": "singleSelect",
"label": "Proxy Type",
"options": {
"disableSearch": true,
"autoCompleteFields": [
{
"value": "http",
"label": "http"
},
{
"value": "socks4",
"label": "socks4"
},
{
"value": "socks5",
"label": "socks5"
}
]
},
"defaultValue": "http",
"field": "proxy_type"
},
{
"type": "text",
"label": "Host",
"validators": [
{
"type": "string",
"errorMsg": "Max host length is 4096",
"minLength": 0,
"maxLength": 4096
}
],
"field": "proxy_url"
},
"type": "proxyTab"
}
```

This creates the tab seen in the image above with 3 default entities that are `Enable` (checkbox for enabling proxy), `Host` (proxy host) and `Port` (proxy port).

### Available configurations

Below are the available properties that can be used while configuring `proxy`. Properties like `name`, `title`, `enable proxy`, `host` and `port` are auto generated (if [minimal defination](#minimal-definition) of proxy is provided).

- Name (auto generated):

```
proxy
```

- Title (auto generated):

```
Proxy
```

- Enable proxy (auto generated) :

```json
{
"type": "checkbox",
"label": "Enable",
"field": "proxy_enabled"
}
```

- Proxy type :

```json
{
"type": "singleSelect",
"label": "Proxy Type",
"required": false,
"options": {
"disableSearch": true,
"autoCompleteFields": [
{"value": "http", "label": "http"},
{"value": "socks4", "label": "socks4"},
{"value": "socks5", "label": "socks5"},
],
},
"defaultValue": "http",
"field": "proxy_type",
}
```

- Host (auto generated) :

```json
{
"type": "text",
"label": "Host",
"validators": [
{
"type": "text",
"label": "Port",
"validators": [
{
"type": "number",
"range": [
1,
65535
]
}
],
"field": "proxy_port"
"type": "string",
"errorMsg": "Max host length is 4096",
"minLength": 0,
"maxLength": 4096,
},
{
"type": "text",
"label": "Username",
"validators": [
{
"type": "string",
"errorMsg": "Max length of username is 50",
"minLength": 0,
"maxLength": 50
}
],
"field": "proxy_username"
"type": "regex",
"errorMsg": "Proxy Host should not have special characters",
"pattern": "^[a-zA-Z]\\w*$",
},
],
"field": "proxy_url",
}
```

- Port (auto generated) :

```json
{
"type": "text",
"label": "Port",
"validators": [{"type": "number", "range": [1, 65535], "isInteger": true}],
"field": "proxy_port",
}
```

- Username :

```json
{
"type": "text",
"label": "Username",
"validators": [
{
"type": "text",
"label": "Password",
"validators": [
{
"type": "string",
"errorMsg": "Max length of password is 8192",
"minLength": 0,
"maxLength": 8192
}
],
"encrypted": true,
"field": "proxy_password"
},
"type": "string",
"errorMsg": "Max length of username is 50",
"minLength": 0,
"maxLength": 50,
}
],
"field": "proxy_username",
}
```

- Password :

```json
{
"type": "text",
"label": "Password",
"validators": [
{
"type": "checkbox",
"label": "Reverse DNS resolution",
"field": "proxy_rdns"
"type": "string",
"errorMsg": "Max length of password is 8192",
"minLength": 0,
"maxLength": 8192,
}
],
"options": {
"saveValidator": "function(formData) { if(!formData.proxy_enabled || formData.proxy_enabled === '0') {return true; } if(!formData.proxy_url) { return 'Proxy Host can not be empty'; } if(!formData.proxy_port) { return 'Proxy Port can not be empty'; } return true; }"
"encrypted": true,
"field": "proxy_password",
}
```

- DNS Resolution checkbox :

```json
{
"type": "checkbox",
"label": "DNS resolution",
"field": "proxy_rdns",
}
```


When only `"type": "proxyTab"` is specified in the globalConfig file, the following entities will be generated by default `host`, `port`, `enable proxy`.

Entities such as `proxy_type`, `username`, `password`, and `dns_resolution` will not be included by default.
To include these optional entities in your add-on, you must explicitly set them to `True` in your configuration. For details on available configurations, refer to the [available configurations](#available-configurations) section.

### Usage

It is placed just like every other configuration tab.

```json
{
"pages": {
"configuration": {
"tabs": [
{
"type": "proxyTab"
}
],
"title": "Configuration",
"description": "..."
}
}
}
```

The example above creates the following form:
To customize these default configurations, you can define them in JSON format by specifying certain keys unique to each entity (refer the [keys section](#keys) for details on the required keys for each entity). When creating the JSON, you only need to include the values you want to customize. For example, if you don’t need to modify fields like `lable` or `field`, you can skip including them in your globalConfig. For better understanding, refer to the provided [Example](#example) which demonstrates how to apply customizations effectively.

> **_NOTE:_**
There are 2 ways to exclude optional entities in your add-on, either omit them from the proxy tab, or set the entities to false.

### Keys
kkedziak-splunk marked this conversation as resolved.
Show resolved Hide resolved

| Key Name | Description |
|----------------|--------------------------------------------------------------------|
| name | Name of the proxy |
| title | Title of proxy tab |
| enable_proxy | Whether proxy should be enabled |
| proxy_type | Type of Proxy communication protocols supported. Default: `SOCKS4`, `SOCKS5`, `HTTP` |
| host | Hostname (FQDN, IPv6 or IPv4) of the Proxy server |
| port | Port of the Proxy server that accepts the connection |
| username | Username used to authenticate the access to Proxy Server |
| password | Password for the provided username to authenticate access to Proxy Server |
| dns_resolution | Whether DNS resolution should be done by Proxy server or not |


### Example

![image](../images/configuration/configuration_without_table_output.png)
```json
{
"type": "proxyTab",
"name": "custom_proxy",
"warning": {
"config": {
"message": "Some warning message"
}
},
"port": {
"label": "Proxy port",
"validator": [
{
"type": "number",
"range": [
1025,
65535
],
"isInteger": true
}
]
},
"username": true,
"password": {
"label": "Password for Proxy"
},
"dns_resolution": false,
}
```

The above will get converted to the older definition (mentioned below) in your output directory.

![image](../images/configuration/proxy_tab_custom.png)

```json
{
--8<-- "tests/unit/tabs/test_proxy_tab.py:9:69"
}
```
Binary file added docs/images/configuration/proxy_tab.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading