Skip to content

Enable CFSClean network isolation for Python pipelines - #48483

Open
Daniel Jurek (danieljurek) wants to merge 9 commits into
mainfrom
djurek/python-cfs-compliance
Open

Enable CFSClean network isolation for Python pipelines#48483
Daniel Jurek (danieljurek) wants to merge 9 commits into
mainfrom
djurek/python-cfs-compliance

Conversation

@danieljurek

@danieljurek Daniel Jurek (danieljurek) commented Aug 6, 2026

Copy link
Copy Markdown
Member

Bring python - pullrequest (and friends) into CFSClean network-isolation compliance

Part of the S360/SFI network-isolation effort. This enables the CFSClean policy and fixes the two things that were violating it.

Changes

File Change
eng/pipelines/templates/stages/1es-redirect.yml networkIsolationPolicy: PermissivePermissive, CFSClean
eng/tools/azure-sdk-tools/ci_tools/variables.py PIP_EXTRA_INDEX_URL → ADO feed instead of pypi.python.org
eng/scripts/seed-virtualenv-wheels.ps1 same

Root cause

PipAuthenticate@1 sets only PIP_INDEX_URL. DEFAULT_ENVIRONMENT_VARIABLES is applied via os.environ.setdefault, so the hardcoded PIP_EXTRA_INDEX_URL=https://pypi.python.org/simple survived authentication and was appended to every dependency resolution in every isolated venv (apistub, pyright, verifytypes, mypy, sphinx, …).

Smoking gun from a baseline run:

[azure-ai-agentserver-core :: apistub] Looking in indexes: ******pkgs.dev.azure.com/.../pypi/simple, https://pypi.python.org/simple

Two pre-existing local workarounds corroborate this — ci_tools/scenario/generation.py passes PIP_EXTRA_INDEX_URL="", and eng/common/pipelines/templates/steps/python-auth-dev-feed.yml clears it outright. This fixes it at the source instead.

Validation

Baseline of 14 recent def-7050 builds: 9/14 NOT COMPLIANT for CFSClean, concentrated in Analyze and Build Extended.

Domain Baseline records After
pypi.org 1,360 0
pypi.python.org 1,306 0
files.pythonhosted.org 874 0

Final run 6670611succeeded, CFSClean COMPLIANT 13/13, with real package targeting (azure-core, azure-keyvault-secrets, azure-template), so package checks genuinely executed rather than being skipped.

Note for reviewers: an eng/-only diff yields TargetingString=null, which silently skips every package check and produces a false clean network-isolation result. Validation runs for this PR deliberately touched package files to force real targeting; those touches have been reverted.

pyright / verifytypes under enforcement

pyright-python self-checks https://pypi.org/pypi/pyright/json on startup to warn about new versions. Under CFSClean that request is now blocked — verified harmless:

  • mureq.get(..., timeout=1) caps the wait at 1s; a bare except Exception swallows it and returns None, so no warning is printed and nothing raises.
  • Run Pyright succeeded in 8.5s, Run verifytypes in 35.3s.
  • The WARNING: there is a new pyright version available line present in baseline logs is absent here, confirming the call was blocked and handled gracefully.
  • The bundled pyright dist is used, so registry.npmjs.org is never contacted either.

Optionally, PYRIGHT_PYTHON_IGNORE_WARNINGS=1 would skip the request entirely (~1s saved per check), but it is not required for correctness.

Out of scope (still non-compliant under other policies)

  • CFSClean2www.powershellgallery.com from pwsh (eng/common/scripts/Helpers/PSModule-Helpers.ps1). Lives in eng/common, so it must be fixed in Azure/azure-sdk-tools and synced.
  • Default Deny — sphinx intersphinx_mapping reaching readthedocs-family domains (doc/sphinx/conf.py).

Neither affects CFSClean.

The default PIP_EXTRA_INDEX_URL was https://pypi.python.org/simple, which is
applied by set_envvar_defaults() across ~18 azpysdk checks. Every pip
invocation in those checks therefore probed public PyPI alongside the CFS
feed, producing the bulk of the CFSClean network isolation violations
observed in the "python - pullrequest" pipeline.

Point both the shared default and the virtualenv seeding script at the
azure-sdk-for-python Azure Artifacts feed, which has an upstream to PyPI.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 6f9d7432-df2e-4c67-8838-bde213908a16
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
10 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Validation-only commit. The PR otherwise touches eng/ only, so the
diff-driven package resolution produced TargetingString=null and every
package check (apistub, pyright, verifytypes, mypy, whl/sdist) was
skipped -- which made the network isolation result a false negative.

Revert before merge.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 6f9d7432-df2e-4c67-8838-bde213908a16
@danieljurek
Daniel Jurek (danieljurek) marked this pull request as ready for review August 7, 2026 01:03
Copilot AI balanced review requested due to automatic review settings August 7, 2026 01:03
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
10 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Routes Python package resolution through the CFS-backed Azure DevOps feed and enables CFSClean pipeline enforcement.

Changes:

  • Replaces public PyPI extra-index defaults with the CFS feed.
  • Enables Permissive, CFSClean network isolation.

Reviewed changes

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

File Description
eng/tools/azure-sdk-tools/ci_tools/variables.py Updates the default pip extra index.
eng/scripts/seed-virtualenv-wheels.ps1 Seeds virtualenv wheels through CFS.
eng/pipelines/templates/stages/1es-redirect.yml Enables CFSClean enforcement.

"VIRTUALENV_PIP": "24.0",
"VIRTUALENV_SETUPTOOLS": "75.3.2",
"PIP_EXTRA_INDEX_URL": "https://pypi.python.org/simple",
"PIP_EXTRA_INDEX_URL": "https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-python/pypi/simple/",
@danieljurek Daniel Jurek (danieljurek) changed the title Point PIP_EXTRA_INDEX_URL at the CFS feed instead of public PyPI Enable CFSClean network isolation for Python pipelines Aug 7, 2026
Repointing PIP_EXTRA_INDEX_URL at the CFS feed made it redundant rather
than correct. azpysdk.main already defaults PIP_INDEX_URL and
UV_DEFAULT_INDEX to CFS_INDEX_URL when unset (main.py:198-201), and
use-python-version.yml does the same at pipeline level -- both using
"set only if unset" so PipAuthenticate@1's authenticated URL wins in CI.

Keeping an extra index pointed at that same feed had three downsides:
it was unauthenticated, it made pip query the same index twice per
resolution, and it leaked the CFS feed into `azpysdk --pypi` runs, which
explicitly set PIP_INDEX_URL to pypi.org and are meant to resolve from
PyPI only.

seed-virtualenv-wheels.ps1 runs virtualenv --download outside azpysdk, so
it does not inherit that defaulting. It now prefers an already-set
PIP_INDEX_URL and only falls back to the public CFS feed, matching the
pattern in use-python-version.yml.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 6f9d7432-df2e-4c67-8838-bde213908a16
Validation-only. Without a package file in the diff the resolver yields
TargetingString=null and every package check is skipped, which makes the
network isolation result a false negative. Revert before merge.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 6f9d7432-df2e-4c67-8838-bde213908a16
Copilot AI review requested due to automatic review settings August 7, 2026 16:32
@danieljurek
Daniel Jurek (danieljurek) requested a review from a team as a code owner August 7, 2026 16:32
Validation-only. Without a package file in the diff the resolver yields
TargetingString=null and every package check is skipped, making the
network isolation result a false negative.

Targets three deliberately different shapes:
  - azure-keyvault-secrets: ordinary data-plane client
  - azure-core: root dependency, rebuilt/revalidated widely
  - azure-storage-extensions: the repo's only C-extension package, so it
    exercises the cibuildwheel path (native build containers, and the
    bundled nuget.exe that reaches api.nuget.org) that the other two do not

Revert before merge.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 6f9d7432-df2e-4c67-8838-bde213908a16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

Suppressed comments (1)

sdk/keyvault/azure-keyvault-secrets/README.md:380

  • This package-only whitespace change contradicts the PR description's statement that the temporary targeting touches were reverted, and it leaves an unrelated package in the final change/targeting set. Please remove the added blank line so the PR remains scoped to the three network-isolation files.

Copilot AI review requested due to automatic review settings August 7, 2026 16:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

Suppressed comments (3)

sdk/storage/azure-storage-extensions/README.md:51

  • The PR description says these validation-only package touches were reverted, but this marker is still present and explicitly says to revert it before merge. Remove it so the unrelated package README is not changed by this infrastructure PR.
<!-- Trivial change to exercise CI network-isolation validation. Revert before merge. -->

sdk/keyvault/azure-keyvault-secrets/README.md:381

  • The PR description says these validation-only package touches were reverted, but this marker is still present and explicitly says to revert it before merge. Remove it so the unrelated package README is not changed by this infrastructure PR.
<!-- Trivial change to exercise CI network-isolation validation. Revert before merge. -->

sdk/core/azure-core/README.md:281

  • The PR description says these validation-only package touches were reverted, but this marker is still present and explicitly says to revert it before merge. Remove it so the unrelated package README is not changed by this infrastructure PR.
<!-- Trivial change to exercise CI network-isolation validation. Revert before merge. -->

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