Skip to content

feat: base code for supporting custom search command #1693

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

Merged
merged 14 commits into from
May 13, 2025

Conversation

hetangmodi-crest
Copy link
Contributor

@hetangmodi-crest hetangmodi-crest commented Apr 15, 2025

Issue number: ADDON-76780, ADDON-79646

PR Type

What kind of change does this PR introduce?

  • Feature
  • Bug Fix
  • Refactoring (no functional or API changes)
  • Documentation Update
  • Maintenance (dependency updates, CI, etc.)

Summary

Changes

This PR contains the centralized code which is required for supporting the custom search command feature.

From this branch we will be having at least 3 separate PR's

User experience

No change in the user experience as of now. As we have not covered generation of files in this PR.

Checklist

If an item doesn't apply to your changes, leave it unchecked.

Review

  • self-review - I have performed a self-review of this change according to the development guidelines
  • Changes are documented. The documentation is understandable, examples work (more info)
  • PR title and description follows the contributing principles
  • meeting - I have scheduled a meeting or recorded a demo to explain these changes (if there is a video, put a link below and in the ticket)

Tests

See the testing doc.

  • Unit - tests have been added/modified to cover the changes
  • Smoke - tests have been added/modified to cover the changes
  • UI - tests have been added/modified to cover the changes
  • coverage - I have checked the code coverage of my changes (see more)

Demo/meeting:

Reviewers are encouraged to request meetings or demos if any part of the change is unclear

@hetangmodi-crest hetangmodi-crest added the enhancement New feature or request label Apr 15, 2025
@hetangmodi-crest hetangmodi-crest self-assigned this Apr 15, 2025
@@ -58,7 +65,7 @@ def _validate_config_against_schema(self) -> None:
Validates config against JSON schema.
Raises jsonschema.ValidationError if config is not valid.
"""
schema_path = os.path.join(self._source_dir, "schema", "schema.json")
schema_path = os.path.join(self._internal_root_dir, "schema", "schema.json")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this change?

Copy link
Contributor Author

@hetangmodi-crest hetangmodi-crest Apr 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "source_dir" seemed an ambiguous variable name - does source_dir point to source code of add-on that is being built or UCC code source, hence, I have renamed the _source_dir to _internal_root_dir, otherwise there is no functionality change.

from splunk_add_on_ucc_framework.const import SPLUNK_COMMANDS


def test_command_list_up_to_date():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure it belongs to the unit tests. Maybe a script that eventually runs periodically.

@kkedziak-splunk @sgoral-splunk what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way that ServiceNow add-on commands are mentioned in the Splunk docs, and if we make this list periodically updated, we won't be able to know if Splunk ever introduced new commands in its docs that actually belong to an add-on. Hence, I think keeping this as a test (as contributed by @kkedziak-splunk) would make more sense, as we would require a human to verify the alteration in command list, if it ever happens.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we will be able to fetch data without snow commands from this url: "https://docs.splunk.com/Documentation/Splunk/9.4.1/SearchReference/ListOfSearchCommands" ?
this way we would be able to periodically update base commands via auto scripts. If no, I'm ok to go with this "test" approach.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@artemrys do you propose to schedule a github workflow with a cron schedule?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe let's proceed with this approach for now and we will see how it works. If needed we can create ticket to change that later. What do you think @hetangmodi-crest @kkedziak-splunk @artemrys ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have created the ticket for it. We can look into it later.
ADDON-80607

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this PR does not generate these files, let's leave them out.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same below.

Copy link
Contributor Author

@hetangmodi-crest hetangmodi-crest Apr 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These files are not generated, they are intended to contain the search command logic and must be provided by the user.
Removing them will cause the build to fail because of this validation. We cannot move the validation elsewhere, as this is a pre-check for generating custom command files.

from splunk_add_on_ucc_framework.const import SPLUNK_COMMANDS


def test_command_list_up_to_date():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we will be able to fetch data without snow commands from this url: "https://docs.splunk.com/Documentation/Splunk/9.4.1/SearchReference/ListOfSearchCommands" ?
this way we would be able to periodically update base commands via auto scripts. If no, I'm ok to go with this "test" approach.

@sgoral-splunk
Copy link
Contributor

@hetangmodi-crest fossa is failing so let's rebase after ucc-gen validation changes are reverted

kkedziak-splunk
kkedziak-splunk previously approved these changes May 8, 2025
**Issue number:** ADDON-76780

### PR Type

**What kind of change does this PR introduce?**
* [x] Feature
* [ ] Bug Fix
* [ ] Refactoring (no functional or API changes)
* [x] Documentation Update
* [ ] Maintenance (dependency updates, CI, etc.)

## Summary

### Changes

This PR includes the generation of the `searchbnf.conf` file for the
custom search command.

### User experience

After defining a valid configuration for the custom search command in
`globalConfig.json`, the `searchbnf.conf` file will be generated.

## Checklist

If an item doesn't apply to your changes, leave it unchecked.

### Review

* [x] self-review - I have performed a self-review of this change
according to the [development
guidelines](https://splunk.github.io/addonfactory-ucc-generator/contributing/#development-guidelines)
* [x] Changes are documented. The documentation is understandable,
examples work [(more
info)](https://splunk.github.io/addonfactory-ucc-generator/contributing/#documentation-guidelines)
* [x] PR title and description follows the [contributing
principles](https://splunk.github.io/addonfactory-ucc-generator/contributing/#pull-requests)
* [ ] meeting - I have scheduled a meeting or recorded a demo to explain
these changes (if there is a video, put a link below and in the ticket)

### Tests

See [the testing
doc](https://splunk.github.io/addonfactory-ucc-generator/contributing/#build-and-test).

* [x] Unit - tests have been added/modified to cover the changes
* [x] Smoke - tests have been added/modified to cover the changes
* [ ] UI - tests have been added/modified to cover the changes
* [x] coverage - I have checked the code coverage of my changes [(see
more)](https://splunk.github.io/addonfactory-ucc-generator/contributing/#checking-the-code-coverage)

**Demo/meeting:**

*Reviewers are encouraged to request meetings or demos if any part of
the change is unclear*
**Issue number:** ADDON-76780, ADDON-79647

### PR Type

**What kind of change does this PR introduce?**
* [x] Feature
* [ ] Bug Fix
* [ ] Refactoring (no functional or API changes)
* [x] Documentation Update
* [ ] Maintenance (dependency updates, CI, etc.)

## Summary

### Changes

This PR includes the generation of the `commands.conf` file for the
custom search command.

### User experience

After defining a valid configuration for the custom search command in
`globalConfig.json`, the `commands.conf` file will be generated.
## Checklist

If an item doesn't apply to your changes, leave it unchecked.

### Review

* [x] self-review - I have performed a self-review of this change
according to the [development
guidelines](https://splunk.github.io/addonfactory-ucc-generator/contributing/#development-guidelines)
* [x] Changes are documented. The documentation is understandable,
examples work [(more
info)](https://splunk.github.io/addonfactory-ucc-generator/contributing/#documentation-guidelines)
* [x] PR title and description follows the [contributing
principles](https://splunk.github.io/addonfactory-ucc-generator/contributing/#pull-requests)
* [ ] meeting - I have scheduled a meeting or recorded a demo to explain
these changes (if there is a video, put a link below and in the ticket)

### Tests

See [the testing
doc](https://splunk.github.io/addonfactory-ucc-generator/contributing/#build-and-test).

* [x] Unit - tests have been added/modified to cover the changes
* [x] Smoke - tests have been added/modified to cover the changes
* [ ] UI - tests have been added/modified to cover the changes
* [x] coverage - I have checked the code coverage of my changes [(see
more)](https://splunk.github.io/addonfactory-ucc-generator/contributing/#checking-the-code-coverage)

**Demo/meeting:**

*Reviewers are encouraged to request meetings or demos if any part of
the change is unclear*
**Issue number:** ADDON-76780

### PR Type

**What kind of change does this PR introduce?**
* [x] Feature
* [ ] Bug Fix
* [ ] Refactoring (no functional or API changes)
* [x] Documentation Update
* [ ] Maintenance (dependency updates, CI, etc.)

## Summary

### Changes

This PR contains generation of template `python files` (which will
import logic from the files provided by the users) for the custom search
command.
For now, we are not supporting generation of python files for
`Transforming/Reporting` command.

### User experience

After defining required and valid configuration for custom search
command in globalconfig.json, required template python files (based on
the command type specified by the user) will be generated for the users,
which will import logic from the files provided by the users.

## Checklist

If an item doesn't apply to your changes, leave it unchecked.

### Review

* [x] self-review - I have performed a self-review of this change
according to the [development
guidelines](https://splunk.github.io/addonfactory-ucc-generator/contributing/#development-guidelines)
* [x] Changes are documented. The documentation is understandable,
examples work [(more
info)](https://splunk.github.io/addonfactory-ucc-generator/contributing/#documentation-guidelines)
* [x] PR title and description follows the [contributing
principles](https://splunk.github.io/addonfactory-ucc-generator/contributing/#pull-requests)
* [ ] meeting - I have scheduled a meeting or recorded a demo to explain
these changes (if there is a video, put a link below and in the ticket)

### Tests

See [the testing
doc](https://splunk.github.io/addonfactory-ucc-generator/contributing/#build-and-test).

* [x] Unit - tests have been added/modified to cover the changes
* [x] Smoke - tests have been added/modified to cover the changes
* [ ] UI - tests have been added/modified to cover the changes
* [x] coverage - I have checked the code coverage of my changes [(see
more)](https://splunk.github.io/addonfactory-ucc-generator/contributing/#checking-the-code-coverage)

**Demo/meeting:**

*Reviewers are encouraged to request meetings or demos if any part of
the change is unclear*
sgoral-splunk
sgoral-splunk previously approved these changes May 13, 2025
Copy link

Code Coverage 🎉

Type PR Develop Change Status
Line Coverage 88.25% 87.84% 0.41% 🟢 Increased
Branch Coverage 81.94% 81.33% 0.61% 🟢 Increased

@hetangmodi-crest hetangmodi-crest merged commit 03cb0d2 into develop May 13, 2025
94 checks passed
@hetangmodi-crest hetangmodi-crest deleted the feat/add-validations-for-csc branch May 13, 2025 12:58
@github-actions github-actions bot locked and limited conversation to collaborators May 13, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request size/XXL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants