internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: svthalia/concrexit

Issue:
Support WebAuthn 2FA
### What?
Add WebAuthn as 2FA option. Or maybe even look into supporting it as a first-factor.

### Why?
WebAuthn may be more practical than TOTP for many of our members, so it can help make 2FA be adopted more.

### How?
Probably some settings that need to be set up, and looking over the templates changed in #3572, and any other templates that need to be updated to make it look good.



Discussion:

Resolving patch:
diff --git a/website/thaliawebsite/settings.py b/website/thaliawebsite/settings.py
--- a/website/thaliawebsite/settings.py
+++ b/website/thaliawebsite/settings.py
@@ -172,6 +172,10 @@ def from_env(
 # How many reference faces a user can have at the same time
 FACEDETECTION_MAX_NUM_REFERENCE_FACES = 5
 
+# webauthn settings
+TWO_FACTOR_WEBAUTHN_RP_NAME = "Thalia"
+TWO_FACTOR_WEBAUTHN_RP_ID = SITE_DOMAIN
+
 # ARN of the concrexit-facedetection-lambda function.
 # See https://github.com/svthalia/concrexit-facedetection-lambda.
 FACEDETECTION_LAMBDA_ARN = os.environ.get("FACEDETECTION_LAMBDA_ARN")
@@ -623,6 +627,7 @@ def show_toolbar(request):
     "shortlinks.apps.ShortLinkConfig",
     "sales.apps.SalesConfig",
     "moneybirdsynchronization.apps.MoneybirdsynchronizationConfig",
+    "two_factor.plugins.webauthn",
 ]
 
 MIDDLEWARE = [


Test patch:
Repository: svthalia/concrexit

Issue:
Unexpected description/clarification on form field in registration form
### Describe the bug

On the page to register as a Thalia member, there is a form field with an explanation/clarification saying 'Warning: changing this in the admin does not update the contribution.' Please see the screenshot below.

### How to reproduce

Go to the ['Become a Member'](https://thalia.nu/association/register/member/) page. You'll see it :)

### Expected behaviour

That the text would not be there.

### Screenshots

![image](https://github.com/svthalia/concrexit/assets/9899175/8dfcdc16-e248-4872-a4af-86563bcc81dd)

### Additional context

N/A



Discussion:

Resolving patch:
diff --git a/website/registrations/forms.py b/website/registrations/forms.py
--- a/website/registrations/forms.py
+++ b/website/registrations/forms.py
@@ -47,6 +47,7 @@ def __init__(self, *args, **kwargs):
             )
         )
         self.fields["birthday"].widget.input_type = "date"
+        self.fields["length"].help_text = None
 
     def clean(self):
         if self.cleaned_data.get("phone_number") is not None:  # pragma: no cover


Test patch:
Repository: svthalia/concrexit

Issue:
Rate-limit and stricter validation on member registration view
See responsible disclosure email. https://staging.thalia.nu/association/register/member/ triggers sending an email. We should ratelimit it quite strictly. 

This email also contains information (name, more?) provided by the user. While that information is properly HTML-escaped, some mail clients do render urls in it as clickable. And for example inserting newlines may be possible, so that someone could at least make the emails ugly. 
So it wouldn't hurt to perform some extra validation of names. 


Discussion:
The reporter would appreciata a note at website/singlepages/templates/singlepages/responsible_disclosure.html with: 

```
Name - Rhythm
Linkedin profile - https://www.linkedin.com/in/ryh04x
```
<img width="994" alt="image" src="https://github.com/svthalia/concrexit/assets/41264528/273ea7eb-0032-46f4-a823-1bb86d18d2ef">
<img width="666" alt="image" src="https://github.com/svthalia/concrexit/assets/41264528/c42b8deb-97b3-4d9d-b1be-3dcad1684be7">

For some reason, some email clients decide to insert <a> tags around anything that looks like it was meant to be a url. Even in email that already has HTML markup.

So it would be nice to add some validation to some fields to limit what can be entered.
Of course it's important that we do allow enough for people of any nationality to register without issues, so just setting a subset of ascii as allowed characters won't work. But denying certain characters (`/, \, .`?) in names makes sense to me. 


Resolving patch:
diff --git a/website/registrations/views.py b/website/registrations/views.py
--- a/website/registrations/views.py
+++ b/website/registrations/views.py
@@ -14,6 +14,8 @@
 from django.views.generic import CreateView, FormView
 from django.views.generic.base import TemplateResponseMixin, TemplateView
 
+from django_ratelimit.decorators import ratelimit
+
 from members.decorators import membership_required
 from members.models import Membership
 
@@ -138,6 +140,10 @@ def form_valid(self, form):
         emails.send_registration_email_confirmation(form.instance)
         return redirect("registrations:register-success")
 
+    @method_decorator(ratelimit(key="ip", rate="10/d"))
+    def post(self, request, *args, **kwargs):
+        return super().post(request, *args, **kwargs)
+
 
 class MemberRegistrationFormView(BaseRegistrationFormView):
     """View that renders the `member` membership registration form."""


Test patch:
Repository: svthalia/concrexit

Issue:
Sales order admin 400 on filter by exact shift
### Describe the bug
See [CONCREXIT-1DV](https://thalia.sentry.io/issues/5217944171/).

When filtering like this:
<img width="684" alt="image" src="https://github.com/svthalia/concrexit/assets/41264528/b80217b9-aad4-40d0-a591-2ab38cc7d24b">
You get a 400 on e.g. `https://thalia.nu/admin/sales/order/?shift__pk__exact=40`.


### How to reproduce
<!-- Steps to reproduce the behaviour -->
1. Click to filter like above.
2. Get 400.

### Expected behaviour
The button to filter goes to a url that works. For example `https://thalia.nu/admin/sales/order/?shift=40`. But that's not recognized by the UI, so I think the UI needs fixing somehow.



Discussion:

Resolving patch:
diff --git a/website/sales/admin/order_admin.py b/website/sales/admin/order_admin.py
--- a/website/sales/admin/order_admin.py
+++ b/website/sales/admin/order_admin.py
@@ -95,6 +95,7 @@ class OrderShiftFilter(AutocompleteFilter):
     title = _("shift")
     field_name = "shift"
     rel_model = Order
+    use_pk_exact = False
 
     def queryset(self, request, queryset):
         if self.value():
@@ -106,6 +107,7 @@ class OrderMemberFilter(AutocompleteFilter):
     title = _("member")
     field_name = "payer"
     rel_model = Order
+    use_pk_exact = False
 
     def queryset(self, request, queryset):
         if self.value():


Test patch:
Repository: svthalia/concrexit

Issue:
Fix trying to delete moneybird invoice that has already been removed on moneybird
### Describe the bug
[CONCREXIT-1D2](https://thalia.sentry.io/issues/5029597650/)

When trying to delete moneybird external invoices, if they have already been removed on moneybird, it currently cuases this issue where the DELETE request fails with 404. Instead, we can probably just accept that it's already been done (and log a warning).

### How to reproduce
1. Have an invoice that's been synced to moneybird.
2. Delete the invoice from moneybird, and make the payable be deleted from concrexit.
3. When at night we try to delete it from moneybird, get a 404.

### Expected behaviour
When we try to delete it from moneybirds api, we ignore the 404.





Discussion:

Resolving patch:
diff --git a/website/moneybirdsynchronization/services.py b/website/moneybirdsynchronization/services.py
--- a/website/moneybirdsynchronization/services.py
+++ b/website/moneybirdsynchronization/services.py
@@ -177,8 +177,19 @@ def delete_external_invoice(obj):
         return
 
     moneybird = get_moneybird_api_service()
-    moneybird.delete_external_invoice(external_invoice.moneybird_invoice_id)
-    external_invoice.delete()
+    try:
+        moneybird.delete_external_invoice(external_invoice.moneybird_invoice_id)
+    except Administration.NotFound:
+        # The invoice has probably been removed manually from moneybird.
+        # We can assume it no longer exists there, but still, this should not happen
+        # too often, so we log it.
+        logger.warning(
+            "Tried to delete non-existing invoice %s with moneybird ID %s",
+            external_invoice,
+            external_invoice.moneybird_invoice_id,
+        )
+    finally:
+        external_invoice.delete()
 
 
 def synchronize_moneybird():


Test patch:
Repository: svthalia/concrexit

Issue:
Lock admin panel behind 2FA
### What?
<!-- A clear and concise high-level description of what you want to happen. -->
lock the admin panel behind the 2FA functionality

### Why?
<!-- A clear and concise motivation why we should consider implementing this. -->
Admin panel has sensitive data so it should be protected. So requiring 2FA makes sense.

### How?
<!-- Optionally some guidance, ideas, context. -->
Probably nice to have a decorator to be able to lock other things of the site behind 2FA in the future.




Discussion:

Resolving patch:
diff --git a/website/thaliawebsite/admin.py b/website/thaliawebsite/admin.py
--- a/website/thaliawebsite/admin.py
+++ b/website/thaliawebsite/admin.py
@@ -1,6 +1,17 @@
 """Settings for the admin site."""
+
+from django.conf import settings
 from django.contrib import admin
 from django.utils.translation import gettext_lazy as _
 
-admin.site.site_header = _("Thalia administration")
-admin.site.site_title = _("Thalia")
+from django_otp import user_has_device
+
+
+class ThaliaAdminSite(admin.AdminSite):
+    site_header = _("Thalia administration")
+    site_title = _("Thalia")
+
+    def has_permission(self, request):
+        return super().has_permission(request) and (
+            settings.DEBUG or user_has_device(request.user)
+        )
diff --git a/website/thaliawebsite/views.py b/website/thaliawebsite/views.py
--- a/website/thaliawebsite/views.py
+++ b/website/thaliawebsite/views.py
@@ -1,5 +1,6 @@
 """General views for the website."""
 
+from django.contrib import messages
 from django.contrib.admin.views.decorators import staff_member_required
 from django.contrib.auth.views import LogoutView as BaseLogoutView
 from django.contrib.auth.views import PasswordResetView
@@ -10,6 +11,7 @@
 from django.views.generic import ListView, TemplateView
 from django.views.generic.base import View
 
+from django_otp import user_has_device
 from django_ratelimit.decorators import ratelimit
 from two_factor.views import LoginView
 
@@ -58,9 +60,11 @@ def get_context_data(self, **kwargs) -> dict:
         context.update(
             {
                 "page_range": page_range,
-                "base_url": f"{self.request.path}?{querydict.urlencode()}&"
-                if querydict
-                else f"{self.request.path}?",
+                "base_url": (
+                    f"{self.request.path}?{querydict.urlencode()}&"
+                    if querydict
+                    else f"{self.request.path}?"
+                ),
             }
         )
 
@@ -101,5 +105,11 @@ def admin_unauthorized_view(request):
         return redirect(url)
     elif not request.member.is_staff and not request.member.is_superuser:
         raise PermissionDenied("You are not allowed to access the administration page.")
+    elif not user_has_device(request.member):
+        messages.error(
+            request,
+            "You need to set up two-factor authentication to access the administration page.",
+        )
+        return redirect("two_factor:setup")
     else:
         return redirect(request.GET.get("next", "/"))


Test patch:
Repository: facebookresearch/CompilerGym

Issue:
"UnsupportedOperation: fileno" in Colaboratory
## 🐛 Bug

`UnsupportedOperation: fileno` error is raised on environment creation in Google Colaboratory.

## To Reproduce

![image](https://user-images.githubusercontent.com/1636663/102848878-cd9fd600-440d-11eb-9f87-fd0cddf66e67.png)


## Environment

Please fill in this checklist:

- CompilerGym: v0.1.0
- How you installed CompilerGym (conda, pip, source): pip
- OS: Colab hosted runtime


Discussion:
Unable to reproduce locally in ipython:

```py
$ ipython
Python 3.8.5 (default, Sep  4 2020, 02:22:02)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.19.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import compiler_gym

In [2]: import gym

In [3]: env = gym.make("llvm-v0")

In [4]: env.reset()
```

Cheers,
Chris
Also unable to reproduce locally using jupyterlab:

```sh
$ conda create -n jupyter python=3.8
$ conda activate jupyter
$ conda install -c conda-forge jupyterlab
$ python -m ipykernel install --user --name myenv --display-name "Python (conda)"
$ jupyter-lab
```

![image](https://user-images.githubusercontent.com/1636663/103228017-c0ac4680-4927-11eb-9d73-3bf04fe86f26.png)

I found that the error is caused by attempting to pipe `subprocess.Popen()` output to `sys.stderr`:

![image](https://user-images.githubusercontent.com/1636663/103228223-27316480-4928-11eb-9195-5431a8f7da48.png)

In colab, `sys.stderr` is a `ipykernel.iostream.OutStream` (same in Jupter lab).

Resolving patch:
diff --git a/compiler_gym/service/connection.py b/compiler_gym/service/connection.py
--- a/compiler_gym/service/connection.py
+++ b/compiler_gym/service/connection.py
@@ -225,12 +225,7 @@ def __init__(
             cmd.append(f"-v={log_level}")
 
         logging.debug(f"$ {' '.join(cmd)}")
-        self.process = subprocess.Popen(
-            cmd,
-            stdout=sys.stderr,
-            stderr=sys.stderr,
-            env=env,
-        )
+        self.process = subprocess.Popen(cmd, env=env)
 
         # Read the port from a file generated by the service.
         wait_secs = 0.1


Test patch:
Repository: facebookresearch/CompilerGym

Issue:
Add support for Python 3.9
## 🚀 Feature

Add support for python 3.9. This shouldn't require any code changes, but the dependencies may not updating.


Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -84,11 +84,16 @@ def get_tag(self):
     include_package_data=True,
     python_requires=">=3.6",
     classifiers=[
-        "Development Status :: 2 - Pre-Alpha",
+        "Development Status :: 3 - Alpha",
         "Environment :: Console",
         "Intended Audience :: Developers",
         "Intended Audience :: Science/Research",
         "License :: OSI Approved :: MIT License",
+        "Programming Language :: Python :: 3.6",
+        "Programming Language :: Python :: 3.7",
+        "Programming Language :: Python :: 3.8",
+        "Programming Language :: Python :: 3.9",
+        "Programming Language :: Python :: 3",
         "Topic :: Scientific/Engineering :: Artificial Intelligence",
         "Topic :: Software Development :: Compilers",
     ],


Test patch:
diff --git a/.github/workflows/release_test.yaml b/.github/workflows/release_test.yaml
--- a/.github/workflows/release_test.yaml
+++ b/.github/workflows/release_test.yaml
@@ -14,7 +14,7 @@ jobs:
             fail-fast: false
             matrix:
                 os: [ubuntu-latest, macos-latest]
-                python: [3.8]
+                python: [3.9]
 
         steps:
             - uses: actions/checkout@v2
Repository: facebookresearch/CompilerGym

Issue:
Use "." name prefix for hidden lockfiles
## 🚀 Feature

It is a [known limitation](https://github.com/harlowja/fasteners/issues/26) of fasteners that `InterProcessLock` files do not clean up and so will leave the file after use. I don't see any issue with that, but it is a little ugly seeing all of those "*.LOCK" files in the cache directory.

I suggest adopting a naming scheme for lock files that starts with "." so that the files will be hidden by `ls` et al by default.


Discussion:

Resolving patch:
diff --git a/compiler_gym/envs/llvm/legacy_datasets.py b/compiler_gym/envs/llvm/legacy_datasets.py
--- a/compiler_gym/envs/llvm/legacy_datasets.py
+++ b/compiler_gym/envs/llvm/legacy_datasets.py
@@ -419,7 +419,7 @@ def _make_cBench_validator(
     def validator_cb(env: "LlvmEnv") -> Optional[ValidationError]:  # noqa: F821
         """The validation callback."""
         with _CBENCH_DOWNLOAD_THREAD_LOCK:
-            with fasteners.InterProcessLock(cache_path("cBench-v1-runtime-data.LOCK")):
+            with fasteners.InterProcessLock(cache_path(".cBench-v1-runtime-data.lock")):
                 download_cBench_runtime_data()
 
         cbench_data = site_data_path("llvm/cBench-v1-runtime-data/runtime_data")
diff --git a/compiler_gym/util/download.py b/compiler_gym/util/download.py
--- a/compiler_gym/util/download.py
+++ b/compiler_gym/util/download.py
@@ -102,8 +102,8 @@ def download(
     # and download the same resource. If we don't have an ID for the resource
     # then we just lock globally to reduce NIC thrashing.
     if sha256:
-        with fasteners.InterProcessLock(cache_path(f"downloads/{sha256}.lock")):
+        with fasteners.InterProcessLock(cache_path(f"downloads/.{sha256}.lock")):
             return _download(urls, sha256, max_retries)
     else:
-        with fasteners.InterProcessLock(cache_path("downloads/LOCK")):
+        with fasteners.InterProcessLock(cache_path("downloads/.lock")):
             return _download(urls, None, max_retries)


Test patch:
Repository: facebookresearch/CompilerGym

Issue:
CompilerGym cache directory defaults don't doesn't play nicely with shared access machines
## 🐛 Bug

The default locations of the CompilerGym caches are in shared folders. On multi-user machines this can cause permission errors as the directory may be created by one user without write permissions to other users. I propose switching to user-specific defaults like so:

- [x] `COMPILER_GYM_CACHE` -> `/tmp/compiler_gym-$user`
- [x] `COMPILER_YM_TRANSIENT_CACHE` -> `/dev/shm/compiler_gym-$user`



Discussion:

Resolving patch:
diff --git a/compiler_gym/util/runfiles_path.py b/compiler_gym/util/runfiles_path.py
--- a/compiler_gym/util/runfiles_path.py
+++ b/compiler_gym/util/runfiles_path.py
@@ -3,8 +3,8 @@
 # This source code is licensed under the MIT license found in the
 # LICENSE file in the root directory of this source tree.
 """Module for resolving a runfiles path."""
-import getpass
 import os
+from getpass import getuser
 from pathlib import Path
 
 # NOTE(cummins): Moving this file may require updating this relative path.
@@ -72,7 +72,7 @@ def site_data_path(relpath: str) -> Path:
     elif os.environ.get("HOME"):
         return Path("~/.local/share/compiler_gym").expanduser() / relpath
     else:
-        return Path("/tmp/compiler_gym/site_data") / relpath
+        return Path(f"/tmp/compiler_gym_{getuser()}/site_data") / relpath
 
 
 def cache_path(relpath: str) -> Path:
@@ -96,7 +96,7 @@ def cache_path(relpath: str) -> Path:
     elif os.environ.get("HOME"):
         return Path("~/.cache/compiler_gym").expanduser() / relpath
     else:
-        return Path("/tmp/compiler_gym/cache") / relpath
+        return Path(f"/tmp/compiler_gym_{getuser()}/cache") / relpath
 
 
 def transient_cache_path(relpath: str) -> Path:
@@ -120,7 +120,7 @@ def transient_cache_path(relpath: str) -> Path:
     if forced:
         return Path(forced) / relpath
     elif Path("/dev/shm").is_dir():
-        return Path(f"/dev/shm/compiler_gym_{getpass.getuser()}") / relpath
+        return Path(f"/dev/shm/compiler_gym_{getuser()}") / relpath
     else:
         # Fallback to using the regular cache.
         return cache_path(relpath)


Test patch:
Repository: facebookresearch/CompilerGym

Issue:
Required license headers missing
## 🐛 Bug

```
https://github.com/facebookresearch/CompilerGym/blob/development/www/demo_api.py:
The first 16 lines of 'www/demo_api.py' do not contain the patterns:
	(Facebook, Inc(\.|,)? and its affiliates)|([0-9]{4}-present(\.|,)? Facebook)|([0-9]{4}(\.|,)? Facebook)
	Copyright

https://github.com/facebookresearch/CompilerGym/blob/development/www/frontends/compiler_gym/src/App.test.js:
The first 16 lines of 'www/frontends/compiler_gym/src/App.test.js' do not contain the patterns:
	(Facebook, Inc(\.|,)? and its affiliates)|([0-9]{4}-present(\.|,)? Facebook)|([0-9]{4}(\.|,)? Facebook)
	Copyright

https://github.com/facebookresearch/CompilerGym/blob/development/www/frontends/compiler_gym/src/index.js:
The first 16 lines of 'www/frontends/compiler_gym/src/index.js' do not contain the patterns:
	(Facebook, Inc(\.|,)? and its affiliates)|([0-9]{4}-present(\.|,)? Facebook)|([0-9]{4}(\.|,)? Facebook)
	Copyright

https://github.com/facebookresearch/CompilerGym/blob/development/www/frontends/compiler_gym/src/reportWebVitals.js:
The first 16 lines of 'www/frontends/compiler_gym/src/reportWebVitals.js' do not contain the patterns:
	(Facebook, Inc(\.|,)? and its affiliates)|([0-9]{4}-present(\.|,)? Facebook)|([0-9]{4}(\.|,)? Facebook)
	Copyright

https://github.com/facebookresearch/CompilerGym/blob/development/www/frontends/compiler_gym/src/setupTests.js:
The first 16 lines of 'www/frontends/compiler_gym/src/setupTests.js' do not contain the patterns:
	(Facebook, Inc(\.|,)? and its affiliates)|([0-9]{4}-present(\.|,)? Facebook)|([0-9]{4}(\.|,)? Facebook)
	Copyright

https://github.com/facebookresearch/CompilerGym/blob/development/www/frontends/compiler_gym/src/assets/scss/custom.scss:
The first 16 lines of 'www/frontends/compiler_gym/src/assets/scss/custom.scss' do not contain the patterns:
	(Facebook, Inc(\.|,)? and its affiliates)|([0-9]{4}-present(\.|,)? Facebook)|([0-9]{4}(\.|,)? Facebook)
	Copyright
```


Discussion:

Resolving patch:
diff --git a/www/www.py b/www/www.py
--- a/www/www.py
+++ b/www/www.py
@@ -1,3 +1,7 @@
+# Copyright (c) Facebook, Inc. and its affiliates.
+#
+# This source code is licensed under the MIT license found in the
+# LICENSE file in the root directory of this source tree.
 """A CompilerGym API and web frontend.
 
 This exposes an API with five operations:


Test patch:
diff --git a/www/frontends/compiler_gym/src/App.test.js b/www/frontends/compiler_gym/src/App.test.js
--- a/www/frontends/compiler_gym/src/App.test.js
+++ b/www/frontends/compiler_gym/src/App.test.js
@@ -1,3 +1,7 @@
+// Copyright (c) Facebook, Inc. and its affiliates.
+//
+// This source code is licensed under the MIT license found in the
+// LICENSE file in the root directory of this source tree.
 import { render, screen } from '@testing-library/react';
 import App from './App';
Repository: facebookresearch/CompilerGym

Issue:
Use round-robin ordering for leaderboard experiment execution
## 🚀 Feature

Don't repeat all `--n` runs of each benchmark in order, perform 1 run of each benchmark, then proceed to the 2nd run, etc, until all `n` runs have been completed.


Discussion:
Hey! I was checking this repo and I was wondering if you would like some help :P. I am a bit new contributing to open source so lmk if I can help.
Hi @thecoblack, great, thanks for offering to help!

Are you new to development in general or just new to open source? This particular issue may be more advanced then some of the others. I would suggest #148 might be a more suitable starting point.

Cheers,
Chris
I'm just new to open source. Regarding the issue, I've already checked this issue and I might have a solution, but i will check the other one too :). 

Thanks!

Resolving patch:
diff --git a/compiler_gym/leaderboard/llvm_instcount.py b/compiler_gym/leaderboard/llvm_instcount.py
--- a/compiler_gym/leaderboard/llvm_instcount.py
+++ b/compiler_gym/leaderboard/llvm_instcount.py
@@ -246,7 +246,6 @@ def main(argv):
 
             # Repeat the searches for the requested number of iterations.
             benchmarks *= FLAGS.n
-            benchmarks = sorted(benchmarks)
             total_count = len(benchmarks)
 
             # If we are resuming from a previous job, read the states that have


Test patch: