Skip to content

feat(uploads): wrap one-shot nomos, monk and ceu scan endpoints#194

Closed
Valyrian-Code wants to merge 1 commit into
fossology:mainfrom
Valyrian-Code:feat/upload-oneshot-scanners
Closed

feat(uploads): wrap one-shot nomos, monk and ceu scan endpoints#194
Valyrian-Code wants to merge 1 commit into
fossology:mainfrom
Valyrian-Code:feat/upload-oneshot-scanners

Conversation

@Valyrian-Code

@Valyrian-Code Valyrian-Code commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Refs #52.

Adds one-shot scan wrappers (upload_oneshot_nomos / upload_oneshot_monk / upload_oneshot_ceu) for POST /uploads/oneshot/{scanner}.

Closed: these routes are API 1.6.2 / master-only and do not exist in fossology 4.4.0 (the version CI pins), so they 404 there. Will revisit when the CI target includes them.

Refs fossology#52.

Adds three methods to run one-shot scans on a single file without creating a
persistent upload:

- upload_oneshot_nomos() -> POST /uploads/oneshot/nomos (license)
- upload_oneshot_monk()  -> POST /uploads/oneshot/monk (license)
- upload_oneshot_ceu()   -> POST /uploads/oneshot/ceu (copyright/email/URL)

Shared multipart logic lives in a private _run_oneshot() helper. Each returns
the OneShotInfo result (data findings and highlights).

Validated against the OpenAPI spec (API 1.6.2 / Fossology 4.4.0); the
multipart field name is "fileInput". Tests cover live happy paths for all
three scanners, a mocked payload assertion (field name + parsing) and a mocked
500 error path.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: RAJVEER42 <irajveer.bishnoi2310@gmail.com>
Copilot AI review requested due to automatic review settings July 1, 2026 06:11

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR extends the Uploads endpoint wrapper to support Fossology’s “one-shot” scanning APIs, enabling license/copyright scanning of a single local file via multipart upload without creating a persistent upload entry.

Changes:

  • Added a shared private helper _run_oneshot() to POST a local file to /uploads/oneshot/{scanner} using multipart field fileInput.
  • Added three public convenience methods: upload_oneshot_nomos(), upload_oneshot_monk(), and upload_oneshot_ceu().
  • Added integration and mocked tests covering happy paths, multipart payload field name, JSON parsing, and a 500 error path.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
fossology/uploads.py Adds _run_oneshot() helper and three one-shot scan wrapper methods.
tests/test_uploads.py Adds integration + mocked tests for the new one-shot upload scan endpoints.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread fossology/uploads.py
Comment on lines +821 to +845
def _run_oneshot(self, scanner: str, file: str) -> dict:
"""Run a one-shot scan on a single file without storing the results.

:param scanner: the scanner to run ("nomos", "monk" or "ceu")
:param file: local path to the file to scan
:type scanner: str
:type file: str
:return: the scanner result (``data`` findings and ``highlights``)
:rtype: dict
:raises FossologyApiError: if the REST call failed
"""
with open(file, "rb") as fp:
response = self.session.post( # type: ignore
f"{self.api}/uploads/oneshot/{scanner}", # type: ignore
files={"fileInput": fp},
)

if response.status_code == 200:
logger.info(f"One-shot {scanner} scan completed for {file}")
return response.json()

description = f"One-shot {scanner} scan failed for {file}"
raise FossologyApiError(description, response)

def upload_oneshot_nomos(self, file: str) -> dict:
@Valyrian-Code

Copy link
Copy Markdown
Contributor Author

Closing this after verifying against the fossology 4.4.0 container that CI pins (API 1.6.1): the POST /uploads/oneshot/{nomos,monk,ceu} routes don't exist there — they're API 1.6.2 (master) only and 404 against the CI container. Will re-open when the CI target includes them.

@Valyrian-Code Valyrian-Code deleted the feat/upload-oneshot-scanners branch July 1, 2026 17:03
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