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

Add: Support for specifying task type and complementary changes #1059

Merged
merged 5 commits into from
Nov 13, 2023
Merged

Add: Support for specifying task type and complementary changes #1059

merged 5 commits into from
Nov 13, 2023

Conversation

4D617274696E
Copy link
Contributor

What

  • Added the command line argument '--task-type' to specify the type of tasks to generate and add randomly generated reports to:
    • Can be 'container' or 'scan', default: 'container'.
    • Since reports cannot be imported into scan tasks, a workaround is used: a container task is created first, set to alterable, then reports are imported, then the container task is modified and a target, scanner and scan config are added. This automatically transforms the container task into a scan task.
    • Required objects for scan tasks, e.g. targets, are only generated when necessary.
  • Changed logic for timestamp calculation from custom method and 'time' module to standard methods from 'datetime' module.
  • Improved naming of randomly generated objects:
    • Added timestamps to names to make them uniquely identifiable and to prevent duplicated generations.
    • Added comments with extended information.
  • Streamlined some text elements.
  • Formatted with 'black'.

Why

OpenSight Asset requires scan tasks to import data from.

Checklist

  • Tests
  • Checked with pylint.
  • Tested manually by generating 200 reports in several passes, and with a combination of command line arguments. Not every possible combination of command line arguments has been tested.
    • Test environment: gvm-cli 23.10.0 (API version 23.10.1) & GOS 22.04.15

Added the command line argument '--task-type' to specify the type
of tasks to generate and add randomly generated reports to and
made several complementary changes.
@4D617274696E 4D617274696E requested a review from a team as a code owner November 8, 2023 10:45
@greenbonebot greenbonebot enabled auto-merge (rebase) November 8, 2023 10:45
Copy link

github-actions bot commented Nov 8, 2023

Conventional Commits Report

Type Number
Bug Fixes 2
Changed 1
Added 1

🚀 Conventional commits found.

Copy link
Contributor

@bjoernricks bjoernricks left a comment

Choose a reason for hiding this comment

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

Just one small change, please extract the

       (local_date_time + timedelta(seconds=-20))
        .astimezone()
        .replace(microsecond=0)
        .isoformat()

into a reusable function.
something like

def creation_time(delta: int = 0) -> str:
  return local_date_time + timedelta(seconds=delta))
      .astimezone()
      .replace(microsecond=0)
      .isoformat()
  )

@4D617274696E 4D617274696E marked this pull request as draft November 9, 2023 13:43
auto-merge was automatically disabled November 9, 2023 13:43

Pull request was converted to draft

The timestamp calculation has been moved to a dedicated function.
The parameter passed corresponds to seconds.
Quoting is used to filter for the target, previously the first
partially matching target based on gvmd's filtering was set.
@4D617274696E 4D617274696E marked this pull request as ready for review November 13, 2023 09:08
@4D617274696E 4D617274696E marked this pull request as draft November 13, 2023 09:20
@4D617274696E 4D617274696E marked this pull request as ready for review November 13, 2023 09:24
@4D617274696E 4D617274696E marked this pull request as draft November 13, 2023 09:31
@4D617274696E 4D617274696E marked this pull request as ready for review November 13, 2023 09:34
@bjoernricks bjoernricks enabled auto-merge (rebase) November 13, 2023 10:22
@bjoernricks bjoernricks merged commit aa45e8e into greenbone:main Nov 13, 2023
19 checks passed
@4D617274696E 4D617274696E deleted the add-task-type-support branch November 13, 2023 10:56
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.

2 participants