Skip to content

netrc scans refactor#21624

Closed
icing wants to merge 5 commits into
curl:masterfrom
icing:netrc-scanning-refactor
Closed

netrc scans refactor#21624
icing wants to merge 5 commits into
curl:masterfrom
icing:netrc-scanning-refactor

Conversation

@icing
Copy link
Copy Markdown
Contributor

@icing icing commented May 15, 2026

Refactor the netrc scanner. Add test case for checking that the last matched machine with unmatched login does not return the password as success (unit1304).

@icing icing requested a review from bagder May 15, 2026 11:24
Comment thread lib/netrc.c Outdated
@icing icing force-pushed the netrc-scanning-refactor branch from 4f0c863 to 0a7bb4a Compare May 15, 2026 12:25
@bagder bagder requested a review from Copilot May 15, 2026 22:42
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Refactors the internal .netrc parsing/scanning logic to a lexer/scanner approach, updates credential override logic to use the new scanner, and extends unit coverage to ensure .netrc scanning does not incorrectly “succeed” with a password when the requested login does not match.

Changes:

  • Replace Curl_parsenetrc() with Curl_netrc_scan() (hostname + optional user) and rework parsing into a token-based scanner.
  • Update override_login() to use Curl_netrc_scan() and simplify the netrc decision flow.
  • Update unit1304 and add a regression case for “host matched but login mismatched must not yield a password”.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
lib/netrc.c Replaces the legacy .netrc parser with a lexer/scanner implementation and introduces Curl_netrc_scan() plumbing.
lib/netrc.h Updates the public internal API surface: declares Curl_netrc_scan() and removes the old parser prototype.
lib/url.c Switches netrc handling in override_login() to the new scanner and consolidates the credential-selection logic.
tests/unit/unit1304.c Updates tests to the new scanner API and adds a regression test for login mismatch not leaking passwords.

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

Comment thread lib/netrc.c
Comment thread lib/netrc.c
Comment on lines +391 to +397
if(sc->user) {
if(Curl_timestrcmp(sc->user, sc->login))
goto out;
/* We look for a specific user,
* entry is only interesting with password */
sc->found = !!sc->passwd;
}
Comment thread lib/netrc.c Outdated
Comment thread tests/unit/unit1304.c Outdated
icing added 5 commits May 18, 2026 10:29
Refactor the netrc scanner. Add test case for checking that
the last matched machine with unmatched login does not return
the password as success (unit1304).
@icing icing force-pushed the netrc-scanning-refactor branch from 0a7bb4a to 751cd93 Compare May 18, 2026 08:29
@bagder bagder closed this in 4ae1d7c May 18, 2026
outcast36 pushed a commit to greearb/curl that referenced this pull request Jun 3, 2026
Refactor the netrc scanner. Add test case for checking that the last
matched machine with unmatched login does not return the password as
success (unit1304).

Closes curl#21624
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

3 participants