Skip to content

Commit a6e909c

Browse files
authored
Merge pull request #26 from takagibit18/feat/eval-manual-fixture-requests-7205
feat(eval): add reviewed negative-sample fixture from psf/requests#7205
2 parents 5fe3cf7 + 7bf146b commit a6e909c

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"id": "golden_real_requests_netrc_pr7205",
3+
"type": "review",
4+
"source": {
5+
"repo_full_name": "psf/requests",
6+
"pr_number": 7205,
7+
"url": "https://github.com/psf/requests/pull/7205",
8+
"merge_commit_sha": "",
9+
"title": "Fix empty netrc entry usage"
10+
},
11+
"input": {
12+
"diff_text": "diff --git a/src/requests/utils.py b/src/requests/utils.py\nindex 4d3039b200..d113a6ff3e 100644\n--- a/src/requests/utils.py\n+++ b/src/requests/utils.py\n@@ -231,7 +231,7 @@ def get_netrc_auth(url, raise_errors=False):\n try:\n _netrc = netrc(netrc_path).authenticators(host)\n- if _netrc:\n+ if _netrc and any(_netrc):\n # Return with login / password\n login_i = 0 if _netrc[0] else 1\n return (_netrc[login_i], _netrc[2])\ndiff --git a/tests/test_utils.py b/tests/test_utils.py\nindex f9a287af1b..c477c4089a 100644\n--- a/tests/test_utils.py\n+++ b/tests/test_utils.py\n@@ -170,6 +170,16 @@ def test_not_vulnerable_to_bad_url_parsing(self, tmp_path, monkeypatch):\n auth = get_netrc_auth(\"http://example.com:@evil.com/'\")\n assert auth is None\n\n+def test_empty_default_credentials_ignored(self, tmp_path, monkeypatch):\n+ \"\"\"Empty default credentials should not be returned.\"\"\"\n+ netrc_path = tmp_path / \".netrc\"\n+ monkeypatch.setenv(\"NETRC\", str(netrc_path))\n+ with open(netrc_path, \"w\") as f:\n+ f.write(\"machine example.com login user password pass\\ndefault\\n\")\n+\n+ auth = get_netrc_auth(\"http://httpbin.org/\")\n+ assert auth is None\n",
13+
"files": {
14+
"src/requests/utils.py": "def get_netrc_auth(url, raise_errors=False):\n ri = urlparse(url)\n host = ri.hostname\n\n try:\n _netrc = netrc(netrc_path).authenticators(host)\n if _netrc and any(_netrc):\n # Return with login / password\n login_i = 0 if _netrc[0] else 1\n return (_netrc[login_i], _netrc[2])\n except (NetrcParseError, OSError):\n # If there was a parsing error or a permissions issue reading the file,\n # we'll just skip netrc auth unless explicitly asked to raise errors.\n if raise_errors:\n raise\n except (ImportError, AttributeError):\n pass\n",
15+
"tests/test_utils.py": "def test_not_vulnerable_to_bad_url_parsing(self, tmp_path, monkeypatch):\n netrc_path = tmp_path / \".netrc\"\n monkeypatch.setenv(\"NETRC\", str(netrc_path))\n with open(netrc_path, \"w\") as f:\n f.write(\"machine example.com login aaaa password bbbb\\n\")\n auth = get_netrc_auth(\"http://example.com:@evil.com/'\")\n assert auth is None\n\n\ndef test_empty_default_credentials_ignored(self, tmp_path, monkeypatch):\n \"\"\"Empty default credentials should not be returned.\"\"\"\n netrc_path = tmp_path / \".netrc\"\n monkeypatch.setenv(\"NETRC\", str(netrc_path))\n with open(netrc_path, \"w\") as f:\n f.write(\"machine example.com login user password pass\\ndefault\\n\")\n\n auth = get_netrc_auth(\"http://httpbin.org/\")\n assert auth is None\n"
16+
},
17+
"error_log": null
18+
},
19+
"expected": {
20+
"issues": [],
21+
"min_issues": 0,
22+
"max_issues": 0,
23+
"is_empty_annotation": true
24+
},
25+
"metadata": {
26+
"suite": "golden_real",
27+
"tags": [
28+
"github",
29+
"review",
30+
"auth",
31+
"netrc",
32+
"negative-sample"
33+
],
34+
"difficulty": "easy",
35+
"annotated_by": "manual",
36+
"reviewed": true,
37+
"created_at": "2026-04-16T00:00:00+00:00"
38+
}
39+
}

0 commit comments

Comments
 (0)