nebius/SWE-bench-extra huggingface dataset:
Repository: duo-labs/parliament

Issue:
Command for wget'ing IAM docs
Saw this:

https://github.com/duo-labs/parliament/blob/master/utils/update_iam_data.py#L18

As you know, I take a similar approach with policy sentry. I suggest modifying the command to this:

```bash
wget -r -np -k --accept 'list_*.html' --reject 'feedbackno.html','feedbackyes.html' -nc https://docs.aws.amazon.com/IAM/latest/UserGuide/introduction.html
```

This will remove all of the extraneous docs that you don't care about :)

Comments:

Patch:
diff --git a/parliament/statement.py b/parliament/statement.py
index bf663c9..cd9ab34 100644
--- a/parliament/statement.py
+++ b/parliament/statement.py
@@ -632,6 +632,15 @@ class Statement:
         else:
             self.effect_allow = False
 
+        # Check Sid
+        if "Sid" in self.stmt and not re.fullmatch("[0-9A-Za-z]*", self.stmt["Sid"]):
+            self.add_finding(
+                "Statement Sid does match regex [0-9A-Za-z]*",
+                severity.MALFORMED,
+                location={"string": self.stmt},
+            )
+            return False
+
         # Check Action
         if "Action" in self.stmt and "NotAction" in self.stmt:
             self.add_finding(
diff --git a/utils/update_iam_data.py b/utils/update_iam_data.py
index d9e45f9..e8a7b6c 100644
--- a/utils/update_iam_data.py
+++ b/utils/update_iam_data.py
@@ -15,7 +15,7 @@ Setup
 pip install beautifulsoup4
 
 # Download files
-wget -r -np -k -A .html -nc https://docs.aws.amazon.com/IAM/latest/UserGuide/introduction.html
+wget -r -np -k --accept 'list_*.html' --reject 'feedbackno.html','feedbackyes.html' -nc https://docs.aws.amazon.com/IAM/latest/UserGuide/introduction.html
 """
 
 


Test patch:
diff --git a/tests/unit/test_formatting.py b/tests/unit/test_formatting.py
index 98233d9..9a395e1 100644
--- a/tests/unit/test_formatting.py
+++ b/tests/unit/test_formatting.py
@@ -41,6 +41,18 @@ class TestFormatting(unittest.TestCase):
         )
         assert_false(len(policy.findings) == 0, "Policy has no Statement")
 
+    def test_analyze_policy_string_invalid_sid(self):
+        policy = analyze_policy_string(
+            """{
+    "Version": "2012-10-17",
+    "Statement": {
+        "Sid": "Statement With Spaces And Special Chars!?",
+        "Effect": "Allow",
+        "Action": "s3:listallmybuckets",
+        "Resource": "*"}}"""
+        )
+        assert_false(len(policy.findings) == 0, "Policy statement has invalid Sid")
+
     def test_analyze_policy_string_correct_simple(self):
         policy = analyze_policy_string(
             """{
Repository: duo-labs/parliament

Issue:
Validate Statement Id values
If set, the `Sid` field in IAM policies may only contain characters from `(A-Z,a-z,0-9)`. `parliament` should declare a finding if `Sid` has spaces or other invalid characters. 

Comments:

Patch:
diff --git a/parliament/statement.py b/parliament/statement.py
index bf663c9..cd9ab34 100644
--- a/parliament/statement.py
+++ b/parliament/statement.py
@@ -632,6 +632,15 @@ class Statement:
         else:
             self.effect_allow = False
 
+        # Check Sid
+        if "Sid" in self.stmt and not re.fullmatch("[0-9A-Za-z]*", self.stmt["Sid"]):
+            self.add_finding(
+                "Statement Sid does match regex [0-9A-Za-z]*",
+                severity.MALFORMED,
+                location={"string": self.stmt},
+            )
+            return False
+
         # Check Action
         if "Action" in self.stmt and "NotAction" in self.stmt:
             self.add_finding(


Test patch:
diff --git a/tests/unit/test_formatting.py b/tests/unit/test_formatting.py
index 98233d9..9a395e1 100644
--- a/tests/unit/test_formatting.py
+++ b/tests/unit/test_formatting.py
@@ -41,6 +41,18 @@ class TestFormatting(unittest.TestCase):
         )
         assert_false(len(policy.findings) == 0, "Policy has no Statement")
 
+    def test_analyze_policy_string_invalid_sid(self):
+        policy = analyze_policy_string(
+            """{
+    "Version": "2012-10-17",
+    "Statement": {
+        "Sid": "Statement With Spaces And Special Chars!?",
+        "Effect": "Allow",
+        "Action": "s3:listallmybuckets",
+        "Resource": "*"}}"""
+        )
+        assert_false(len(policy.findings) == 0, "Policy statement has invalid Sid")
+
     def test_analyze_policy_string_correct_simple(self):
         policy = analyze_policy_string(
             """{
Repository: duosecurity/duo_client_python

Issue:
Retrieve Endpoint by ID
Would be great if there was a function in the admin client that covered this endpoint.

`/admin/v1/endpoints/[epkey]`

Comments:

Patch:
diff --git a/.github/workflows/python-ci.yml b/.github/workflows/python-ci.yml
index 4b666cd..d61eb4f 100644
--- a/.github/workflows/python-ci.yml
+++ b/.github/workflows/python-ci.yml
@@ -7,7 +7,7 @@ jobs:
 
     strategy:
       matrix:
-        python-version: [2.7, 3.5, 3.6, 3.7, 3.8]
+        python-version: [2.7, 3.5, 3.6, 3.7, 3.8, 3.9]
 
     steps:
       - uses: actions/checkout@v2
diff --git a/duo_client/admin.py b/duo_client/admin.py
index b9d68e6..57a144d 100644
--- a/duo_client/admin.py
+++ b/duo_client/admin.py
@@ -1058,6 +1058,21 @@ class Admin(client.Client):
         params = {}
         return self.json_api_call('DELETE', path, params)
 
+    def get_endpoint(self, epkey):
+        """
+        Get a single endpoint from the AdminAPI by a supplied epkey.
+
+        Params:
+            epkey (str) - The supplied endpoint key to fetch.
+
+        Returns: The endpoint object represented as a dict.
+        Raises:
+            RuntimeError: if the request returns a non-200 status response.
+        """
+        escaped_epkey = six.moves.urllib.parse.quote_plus(str(epkey))
+        path = '/admin/v1/endpoints/' + escaped_epkey
+        return self.json_api_call('GET', path, {})
+
     def get_endpoints_iterator(self):
         """
         Returns iterator of endpoints objects.


Test patch:
diff --git a/tests/admin/test_endpoints.py b/tests/admin/test_endpoints.py
index 8f19861..8a04170 100644
--- a/tests/admin/test_endpoints.py
+++ b/tests/admin/test_endpoints.py
@@ -80,6 +80,19 @@ class TestEndpoints(TestAdmin):
                 'offset': ['20'],
             })
 
+    def test_get_endpoint(self):
+        """ Test getting a single endpoint.
+        """
+        epkey = 'EP18JX1A10AB102M2T2X'
+        response = self.client_list.get_endpoint(epkey)[0]
+        (uri, args) = response['uri'].split('?')
+        self.assertEqual(response['method'], 'GET')
+        self.assertEqual(uri, '/admin/v1/endpoints/' + epkey)
+        self.assertEqual(
+            util.params_to_dict(args),
+            {
+                'account_id': [self.client.account_id],
+            })
 
 if __name__ == '__main__':
     unittest.main()