Skip to content

Conversation

@git-hyagi
Copy link
Contributor

closes: #1272

@git-hyagi git-hyagi force-pushed the add-vuln-report branch 5 times, most recently from 2cdad88 to a720b1e Compare November 14, 2025 20:07
@mdellweg mdellweg marked this pull request as draft November 17, 2025 09:43
Comment on lines 103 to 105
NEEDS_PLUGINS = [PluginRequirement("python", specifier=">=3.1.0")]

def scan(self) -> t.Any:
return self.call("scan", parameters={self.HREF: self.pulp_href})

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
NEEDS_PLUGINS = [PluginRequirement("python", specifier=">=3.1.0")]
def scan(self) -> t.Any:
return self.call("scan", parameters={self.HREF: self.pulp_href})
NEEDS_PLUGINS = [PluginRequirement("python", specifier=">=3.1.0")]
CAPABILITIES = {"scan": [PluginRequirement("python", specifier=">=3.21.0")]}
def scan(self) -> t.Any:
self.needs_capability("scan")
return self.call("scan", parameters={self.HREF: self.pulp_href})

This feature of the CLI is very useful for implementing new endpoints that are shared, but unevenly supported across the plugins.

Copy link
Member

Choose a reason for hiding this comment

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

If scan is going to have the same signature on every repository that supports it, you can move the function up in the hierarchy that way.

Copy link
Member

Choose a reason for hiding this comment

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

I didn't mean all the way up to the base EntityContext.

Comment on lines 62 to 67
needs_plugins: t.List[PluginRequirement] = [PluginRequirement("python", specifier=">=3.21.0")],
) -> None:

# for now, vuln report is implemented for pulp_python only
if not isinstance(repository, PulpPythonRepositoryContext):
return
Copy link
Contributor

Choose a reason for hiding this comment

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

With the CAPABILITIES feature you won't need to check the context type. Just check the capable/needs_capability on the final repository version context to see if you can call scan.

@git-hyagi git-hyagi force-pushed the add-vuln-report branch 2 times, most recently from 876b7cc to 609049f Compare November 17, 2025 18:13
help=_("Version of the repository to scan. Leave blank for latest version."),
)
@pass_pulp_context
def create(
Copy link
Member

Choose a reason for hiding this comment

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

I think, here we should follow the design of the api.
The repository version command group can have a scan subcommand whose sideeffect would be to create a report.

Copy link
Member

Choose a reason for hiding this comment

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

So this command should go away.

@git-hyagi git-hyagi force-pushed the add-vuln-report branch 6 times, most recently from 9672fae to 1154c06 Compare November 19, 2025 13:58
@git-hyagi git-hyagi marked this pull request as ready for review November 19, 2025 14:32
help=_("Version of the repository to scan. Leave blank for latest version."),
)
@pass_pulp_context
def create(
Copy link
Member

Choose a reason for hiding this comment

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

So this command should go away.

@git-hyagi git-hyagi force-pushed the add-vuln-report branch 2 times, most recently from 75a552e to 3d9625a Compare November 19, 2025 15:58
Comment on lines 1287 to 1289
def scan(self) -> t.Any:
return self.call("scan", parameters={self.HREF: self.pulp_href})

Copy link
Member

Choose a reason for hiding this comment

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

What are the objects you can scan? And where did the capability check go?

@git-hyagi git-hyagi requested a review from mdellweg December 4, 2025 19:52
@@ -0,0 +1,30 @@
#!/bin/bash
Copy link
Member

Choose a reason for hiding this comment

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

This should move to pulp_python.

pulp python repository sync --name python --remote python

expect_succ pulp python repository version scan --repository python
expect_succ pulp vulnerability-report list
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't we be able to request the very report we just created here?

expect_succ pulp python repository version scan --repository python
expect_succ pulp vulnerability-report list

VULN_REPORT=$(pulp vulnerability-report list --field pulp_href --limit 1|jq .[0].pulp_href -r)
Copy link
Member

Choose a reason for hiding this comment

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

Please use the result variable from the previously tested command.

Comment on lines 103 to 105
NEEDS_PLUGINS = [PluginRequirement("python", specifier=">=3.1.0")]

def scan(self) -> t.Any:
return self.call("scan", parameters={self.HREF: self.pulp_href})

Copy link
Member

Choose a reason for hiding this comment

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

I didn't mean all the way up to the base EntityContext.

"""
Scan a {entity}.
"""
entity_ctx.needs_capability("scan")
Copy link
Member

Choose a reason for hiding this comment

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

This should be inside the ctx.scan function.

Scan a {entity}.
"""
entity_ctx.needs_capability("scan")
entity_ctx.scan()
Copy link
Member

Choose a reason for hiding this comment

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

Isn't there some thing to tell the user about here?

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 to pulp_python vulnerability report

4 participants