Skip to content

Add Recast Rules API support - #1024

Merged
SteveMcGrath merged 5 commits into
tenable:mainfrom
rksharma-owg:feat/recast-rules-api
Oct 2, 2026
Merged

SteveMcGrath merged 5 commits into
tenable:mainfrom
rksharma-owg:feat/recast-rules-api

Conversation

@rksharma-owg

@rksharma-owg rksharma-owg commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Description

This adds a tio.recast_rules interface for the Tenable Vulnerability Management Recast Rules API. The interface supports creating, searching, retrieving, updating, and deleting rules, along with listing the available rule filters. It validates documented resource types, UUIDs, payload types, and the search limit while passing API-defined filter and sort objects through unchanged.

The interface uses the published /v1/recast/rules paths for all six operations and is included in the generated API documentation. No dependencies are required.

Fixes #967

Type of change

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

How Has This Been Tested?

Request-level tests exercise all six endpoints without live credentials and assert HTTP methods, paths, JSON payloads, response handling, and invalid resource-type/limit behavior.

  • Focused tests: uv run --python 3.12 --isolated --group dev pytest -q -o addopts= tests/io/test_recast_rules.py (4 passed)
  • Full local suite: 2,120 passed, 34 skipped, 6 xfailed, 3 xpassed; 95.51% coverage
  • Ruff: just lint 3.12
  • Code audit: just audit
  • Strict documentation build: uv run --python 3.12 --isolated --group docs sphinx-build -W -b html docs /tmp/pytenable-docs-recast
  • Fork preflight: Python 3.11, 3.12, 3.13, and 3.14 lint/tests/coverage plus code audit against b48a0a4 (run)

Test Configuration:

  • Python Version(s) Tested: 3.11, 3.12, 3.13, 3.14 on Ubuntu; 3.12.13 on macOS
  • Tenable.sc version (if necessary): N/A

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code where behavior is not self-explanatory
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove the feature works
  • New and existing unit tests pass locally with my changes

@rksharma-owg
rksharma-owg requested a review from a team as a code owner September 20, 2026 01:42
@SteveMcGrath

Copy link
Copy Markdown
Contributor

Overall looks good, however I'd want to see more documentation in the docstring. Take a look at this as a good example: https://github.com/tenable/pyTenable/blob/main/tenable/io/agents.py#L44-L100

Comment thread tenable/io/recast_rules.py Outdated


class RecastRulesAPI(TIOEndpoint):
"""The Tenable Vulnerability Management Recast Rules API."""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Improve documentation

Comment thread tenable/io/recast_rules.py Outdated
expires_at: str | None = None,
disabled_details: dict[str, Any] | None = None,
) -> dict[str, Any]:
"""Create a recast rule."""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Improve documentation

Comment thread tenable/io/recast_rules.py Outdated
sort: list[str] | None = None,
next: str | None = None,
) -> dict[str, Any]:
"""Search recast rules."""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Improve documentation

Comment thread tenable/io/recast_rules.py Outdated
return self._api.post('v1/recast/rules/search', json=payload).json()

def details(self, rule_id: str) -> dict[str, Any]:
"""Retrieve a recast rule by UUID."""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Improve documentation

Comment thread tenable/io/recast_rules.py Outdated
expires_at: str | None = None,
disabled_details: dict[str, Any] | None = None,
) -> dict[str, Any]:
"""Update a recast rule by UUID."""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Improve documentation

Comment thread tenable/io/recast_rules.py Outdated
).json()

def delete(self, rule_id: str) -> dict[str, Any]:
"""Delete a recast rule by UUID."""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Improve documentation

Comment thread tenable/io/recast_rules.py Outdated
).json()

def filters(self) -> dict[str, Any]:
"""Retrieve the available recast rule filters."""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Improve documentation

@rksharma-owg

Copy link
Copy Markdown
Contributor Author

I expanded the Recast Rules API docstrings in d2e3402 with parameter descriptions, return values, and usage examples following the existing endpoint style. The current PR checks, including Python 3.11–3.14 unit tests and the documentation build, have passed.

@SteveMcGrath
SteveMcGrath merged commit 8c1c67b into tenable:main Oct 2, 2026
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for the new Recast Rules API

2 participants