Skip to content

XRAY-167265 - jf ca Poetry cache - #945

Merged
gauriy-tech merged 2 commits into
jfrog:devfrom
Phavya-jfrog:feature/XRAY-167265-poetry-cache
Nov 19, 2026
Merged

gauriy-tech merged 2 commits into
jfrog:devfrom
Phavya-jfrog:feature/XRAY-167265-poetry-cache

Conversation

@Phavya-jfrog

@Phavya-jfrog Phavya-jfrog commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

jf ca for Poetry no longer touches the user's Poetry cache or credential store. poetry lock runs against a throw-away cache inside the temp project copy, and it is deleted when the run ends.

Why

poetry lock through the curation URL wrote into the user's real cache, and the source password was saved by poetry config http-basic in the user's keyring or auth.toml. A curation audit should leave nothing on the machine.

Behavior

  • jf ca creates <temp>/.jf-poetry-cache and points Poetry at it (POETRY_CACHE_DIR, POETRY_VIRTUALENVS_PATH). virtualenv's own app-data cache, which Poetry does not control, is redirected into it too (VIRTUALENV_OVERRIDE_APP_DATA), so nothing is written under the user's home on any Poetry version. On Poetry 2+ poetry lock also runs with POETRY_VIRTUALENVS_CREATE=false, as it only needs the lock file. Poetry 1.x keeps creating its virtualenv (inside the isolated cache): 1.2 and 1.4 need distutils without one, which Python 3.12+ no longer has.
  • Just before a poetry lock that resolves, only the release-info part of cache/repositories is copied in, read-only. The HTTP response caches (_http, _http_) are not copied: they are keyed by request URL, which differs for the curation source. A run with an up-to-date poetry.lock skips seeding.
  • The user's cache location is read with the user's own POETRY_CACHE_DIR, and a leading ~ is expanded.
  • Seeding is skipped and the run continues with an empty cache when the user cache is missing, empty, unreadable, over 1 GiB or over 10,000 files (counted without the HTTP caches), or contains a symlink.
  • The source credentials are passed as POETRY_HTTP_BASIC_<NAME>_USERNAME/_PASSWORD instead of poetry config http-basic, so nothing is saved in the keyring or auth.toml, and the password is not on a command line. They are removed from the environment when the run ends.
  • The temp copy and the isolated cache are removed at the end, and also on Ctrl+C or SIGTERM (a running poetry is stopped first).
  • If the isolated cache can't be created, the audit stops with failed to create the isolated Poetry cache: <error>.
  • Only the curation path is affected.

Trade-offs

  • Before this change a second jf ca run could be warm, because poetry lock cached under the user's cache. Now every run starts with an empty cache apart from the seeded release-info, so a user or CI job that only runs jf ca (no committed or up-to-date lock) pays the cold cost each time. A reviewer measured about 122-161 s cold vs about 31 s seeded on a 7-package project over a slow network (19.5 s vs 7 s on a smaller one).
  • Path dependencies (lib = {path = "../lib"}) already fail in the temp copy of the project (that copy predates this PR), so "leaves nothing behind" applies to projects without path dependencies.

Alternatives considered

  • A temp cache with no seeding at all would remove the copy, the limits and the symlink check. poetry lock --no-cache writes nothing to the cache on Poetry 2.4.3, but its speed varied from about 22 s to over 3 minutes with the network, so it is not a drop-in replacement.
  • The limits (1 GiB, 10,000 files) only bound the cost of the copy: a few seconds for a cache of that size on an SSD. They are constants in python.go and there is no opt-out; one can be added if wanted.
  • To roll back, remove the isolatePoetryCache call in installPoetryDeps.

Testing

Unit tests (fake Poetry and real Poetry), plus a manual matrix on Poetry 1.2, 1.4, 1.8, 2.0 and 2.4 against a curation-enabled Artifactory: the user's cache and config are unchanged, nothing is left in the temp dir, and Ctrl+C / SIGTERM at different moments leave nothing behind.

Release note

Improved jf curation-audit for Poetry projects: poetry lock now runs against a temporary, isolated cache that is deleted when the audit ends, so your Poetry cache is no longer modified. The Artifactory credentials are passed to Poetry through environment variables instead of being saved in your keyring or auth.toml.

Related tickets

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI; Enforced overrides: Organization, Workspace
  • Review profile: CHILL
  • Plan: Enterprise
  • Run ID: 92442fcc-a165-43b6-875c-d08d377aba5b

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

@Phavya-jfrog
Phavya-jfrog force-pushed the feature/XRAY-167265-poetry-cache branch from eb85bec to f949445 Compare November 11, 2026 11:16
@Phavya-jfrog Phavya-jfrog added improvement Automatically generated release notes safe to test Approve running integration tests on a pull request labels Nov 11, 2026
@github-actions github-actions Bot removed the safe to test Approve running integration tests on a pull request label Nov 11, 2026
@Phavya-jfrog
Phavya-jfrog force-pushed the feature/XRAY-167265-poetry-cache branch from eb56bdc to b437a2a Compare November 15, 2026 16:31
@Phavya-jfrog
Phavya-jfrog force-pushed the feature/XRAY-167265-poetry-cache branch from b399cde to 196a344 Compare November 15, 2026 16:36
@Phavya-jfrog Phavya-jfrog added the safe to test Approve running integration tests on a pull request label Nov 15, 2026
@github-actions github-actions Bot removed the safe to test Approve running integration tests on a pull request label Nov 15, 2026
@Phavya-jfrog
Phavya-jfrog force-pushed the feature/XRAY-167265-poetry-cache branch from 90156e2 to e5f535d Compare November 16, 2026 06:37
@Phavya-jfrog Phavya-jfrog added the safe to test Approve running integration tests on a pull request label Nov 16, 2026
@github-actions github-actions Bot removed the safe to test Approve running integration tests on a pull request label Nov 16, 2026
@gauriy-tech

Copy link
Copy Markdown
Collaborator

General comment on the PR description (no line target). Could the description also cover a few things a reader will wonder about?

  1. Trade-off: before this change a second jf ca run could be warm, because poetry lock cached under the user's cache. Now every run starts with an empty cache apart from the seeded release-info, so a user or CI job that only runs jf ca (no committed or stale lock) pays the cold cost each time. On one 7-package project I measured about 122-161 s cold vs about 31 s with seeded release-info (slow network; a reviewer saw 19.5 s vs 7 s on a smaller one).
  2. Scope: path dependencies (lib = {path = "../lib"}) fail in the temp copy of the project (CopyDir(wd, tempDirPath) predates this PR), so the "leaves nothing behind" scenario applies to projects without path dependencies.
  3. Alternatives and rollback: for example a temp cache with no seeding at all, which removes the copy, size limits and symlink checks (poetry lock --no-cache writes nothing to the cache on Poetry 2.4.3; its speed varied a lot with network speed in our measurements, from about 22 s to over 3 minutes, so it may not be a drop-in). The seeding limits are hard-coded (python.go:985-987); a note on why 1 GiB / 10,000 files, and whether an opt-out is wanted, would help.

The four PR checklist boxes are also still unchecked.


Review generated by xray-pr-review

@gauriy-tech

Copy link
Copy Markdown
Collaborator

General comment (no line target; the code involved predates this PR, so a follow-up ticket may fit better). The description says a curation audit "should leave nothing on the machine", but when the Artifactory source has a password, the existing poetry config --local http-basic.<name> <user> <pass> call (python.go, in installPoetryDeps) does not stay local: Poetry handles http-basic through its password manager (poetry/console/commands/config.py and utils/password_manager.py: set_http_password), which puts the password in the OS keyring (the username still goes to auth.toml), or in plaintext in auth.toml in Poetry's user config dir when no keyring is usable. --local only affects other settings, such as the repositories.<name> call, which does stay in the temp project's poetry.toml.

With real Poetry 2.4.3, a fake HOME and PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring (simulating a machine without a keyring), after installPoetryDeps and removal of the temp dir the password was still in plaintext in <HOME>/Library/Application Support/pypoetry/auth.toml, and an existing [http-basic.<same name>] entry in that file was overwritten with the curation user and password. The keyring case is from reading Poetry's source, not tested. The password is also visible in the poetry command line while it runs.

Poetry also reads POETRY_HTTP_BASIC_<NAME>_USERNAME / POETRY_HTTP_BASIC_<NAME>_PASSWORD, where <NAME> is the source name upper-cased with - replaced by _ (dots and other characters are kept as they are). With a local stub index, Poetry sent Authorization: Basic with those variables for names like pypi-curation and my.repo-1, with special characters in the password, and nothing was written under HOME. Would setting these through setEnvWithRestore instead of the config call fit here? Replacing POETRY_CONFIG_DIR instead would hide the user's other global settings, so the env route looks safer.


Review generated by xray-pr-review

@Phavya-jfrog
Phavya-jfrog force-pushed the feature/XRAY-167265-poetry-cache branch from 172361b to 02672de Compare November 18, 2026 11:14
@Phavya-jfrog Phavya-jfrog added the safe to test Approve running integration tests on a pull request label Nov 18, 2026
@github-actions github-actions Bot removed the safe to test Approve running integration tests on a pull request label Nov 18, 2026
@gauriy-tech

Copy link
Copy Markdown
Collaborator

Suggested release note for XRAY-167265 (the ticket's release-note field is still empty):

Improved jf curation-audit for Poetry projects: poetry lock now runs against a temporary, isolated cache and credential environment, so your Poetry cache and keyring are no longer modified (and, on Poetry 2 and later, virtualenv data as well).


Review generated by xray-pr-review

@Phavya-jfrog

Copy link
Copy Markdown
Contributor Author

Suggested release note for XRAY-167265 (the ticket's release-note field is still empty):

Improved jf curation-audit for Poetry projects: poetry lock now runs against a temporary, isolated cache and credential environment, so your Poetry cache and keyring are no longer modified (and, on Poetry 2 and later, virtualenv data as well).

Review generated by xray-pr-review

@Phavya-jfrog Phavya-jfrog reopened this Nov 19, 2026
@gauriy-tech gauriy-tech added the safe to test Approve running integration tests on a pull request label Nov 19, 2026
@github-actions github-actions Bot removed the safe to test Approve running integration tests on a pull request label Nov 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

👍 Frogbot scanned this pull request and did not find any new security issues.


@gauriy-tech
gauriy-tech merged commit b223743 into jfrog:dev Nov 19, 2026
71 of 75 checks passed
@Phavya-jfrog
Phavya-jfrog deleted the feature/XRAY-167265-poetry-cache branch November 19, 2026 07:39

This branch was previously deployed

1 inactive deployment
frogbot — bed1198e Deployed Nov 19, 2026 by Phavya-jfrog via scan-pull-request #4831
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement Automatically generated release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants