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 on demand addon_pipeline in /api/collect endpoints #393

Merged
merged 5 commits into from
Apr 23, 2024

Conversation

keshav-space
Copy link
Member

@keshav-space keshav-space commented Apr 17, 2024

  • /api/collect endpoint now supports optional list of addon_pipelines to run on the package.
    Example GET request:

      /api/collect/?purl=pkg:npm/foo@1.2.3&addon_pipelines=collect_symbols&addon_pipelines=inspect_elf_binaries
  • In bulk indexing /api/collect/index_packages/ endpoint each package now also supports optional list of addon_pipelines to run on the package.
    Example POST request:

      {
          "packages": [
              {
                  "purl": "pkg:npm/foobar",
                  "vers": null,
                  "source_purl": None,
                  "addon_pipelines": ['inspect_elf_binaries', 'collect_symbols']
              }
          ]
          "reindex": true,
          "reindex_set": false,
      }
  • fixes PurlDB: make symbols and strings indexing a separate, on demand option #376


Note

If no addon_pipeline is provided, then only the default pipelines will be run on the package.
https://github.com/nexB/purldb/blob/32ea6e810c3c371e24318440f079a7453f1c5d4a/minecode/model_utils.py#L30-L33

Signed-off-by: Keshav Priyadarshi <git@keshav.space>
Signed-off-by: Keshav Priyadarshi <git@keshav.space>
Signed-off-by: Keshav Priyadarshi <git@keshav.space>
Signed-off-by: Keshav Priyadarshi <git@keshav.space>
Signed-off-by: Keshav Priyadarshi <git@keshav.space>
Copy link
Member

@JonoYang JonoYang left a comment

Choose a reason for hiding this comment

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

@keshav-space I just have a question about when the symbol collection pipelines would be run


# These are the list of supported addon pipelines to run when we scan a Package for
# indexing.
SUPPORTED_ADDON_PIPELINES = (
Copy link
Member

Choose a reason for hiding this comment

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

Can you give me an example of when these pipelines would be run when indexing a package. I see how the default pipelines would be run, but where would we add the symbol collecting pipelines when we index a package?

Copy link
Member Author

Choose a reason for hiding this comment

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

@JonoYang
Suppose we receive this request: /api/collect/?purl=pkg:npm/foo@1.2.3&addon_pipelines=collect_symbols.

First, the CollectPackageSerializer will validate whether collect_symbols is a valid pipeline or not using SUPPORTED_ADDON_PIPELINES. Then, will add this package to the scan queue using add_package_to_scan_queue, with the pipeline argument being DEFAULT_PIPELINES + ( 'collect_symbols' ).

Copy link
Member

@JonoYang JonoYang Apr 23, 2024

Choose a reason for hiding this comment

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

@keshav-space I see, do we currently use this anywhere? Otherwise, I think the code looks good unless there's something you want to change.

Copy link
Member Author

Choose a reason for hiding this comment

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

@JonoYang No more change from my side, it's ready for merge.

@JonoYang JonoYang merged commit 72d2b31 into main Apr 23, 2024
8 checks passed
@JonoYang JonoYang deleted the 376-support-on-demand-pipeline branch April 23, 2024 22:22
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.

PurlDB: make symbols and strings indexing a separate, on demand option
2 participants