Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New reports from Webcompat.com does not automatically assign browser labels #2580

Closed
reinhart1010 opened this issue Sep 16, 2018 · 7 comments

Comments

@reinhart1010
Copy link

Starting from webcompat/web-bugs#18835, there are no browser tags such as browser-firefox assigned automatically. This might be related to #2573.

@karlcow
Copy link
Member

karlcow commented Sep 16, 2018

houla o_0 @miketaylr
https://github.com/webcompat/webcompat.com/blob/master/CHANGELOG.md#1320---2018-09-14

the modifications from the pull request #2573 seems innocuous.
Or is it a regression because I changed webhooks? That seems more likely aka #2577 bummer.

@karlcow
Copy link
Member

karlcow commented Sep 17, 2018

Thanks a lot @reinhart1010 for raising this issue.
I have labeled by hand all the unlabeled bugs, and added the needstriage milestone.

@karlcow
Copy link
Member

karlcow commented Sep 17, 2018

ok I think I understood.

→ http HEAD https://webcompat.com/webhooks/labeler

gives

HTTP/1.1 404 NOT FOUND
Connection: keep-alive
Content-Encoding: gzip
Content-Security-Policy: default-src 'self'; object-src 'none'; connect-src 'self' https://api.github.com; font-src 'self' https://fonts.gstatic.com; img-src 'self' https://www.google-analytics.com https://*.githubusercontent.com data:; manifest-src 'self'; script-src 'self' https://www.google-analytics.com https://api.github.com; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; base-uri 'self'; frame-ancestors 'self'; report-uri /csp-report
Content-Type: text/html; charset=utf-8
Date: Mon, 17 Sep 2018 00:33:36 GMT
Server: nginx/1.1.19
Strict-Transport-Security: max-age=31536000; includeSubDomains;
Vary: Accept-Encoding
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block

By removing the blueprint I also removed the knowledge of the route from the main code. Rha.

So let's revert until I figure a way to do this in another way.

@karlcow
Copy link
Member

karlcow commented Sep 17, 2018

🐝 09:38:19 ~/code/webcompat.com
→ git checkout -b 2580/1
Switched to a new branch '2580/1'
🐝 09:38:38 ~/code/webcompat.com
→ python run.py
Writing logs to: /Users/karl/code/webcompat.com/tmp
Statuses Initialization…
Milestones in memory
 * Serving Flask app "webcompat" (lazy loading)
 * Environment: production
   WARNING: Do not use the development server in a production environment.
   Use a production WSGI server instead.
 * Debug mode: on
 * Running on http://localhost:5000/ (Press CTRL+C to quit)
 * Restarting with stat
Writing logs to: /Users/karl/code/webcompat.com/tmp
Statuses Initialization…
Milestones in memory
 * Debugger is active!
 * Debugger PIN: 195-432-804

We know the route should listen only to POST.
and will reply with return ('Nothing to see here', 401, {'Content-Type': 'text/plain'})
if it's not a github request.

→ http POST http://localhost:5000/webhooks/labeler 
HTTP/1.0 405 METHOD NOT ALLOWED
Allow: HEAD, OPTIONS, GET
Content-Length: 178
Content-Security-Policy: default-src 'self'; object-src 'none'; connect-src 'self' https://api.github.com; font-src 'self' https://fonts.gstatic.com; img-src 'self' https://webcompat.com https://www.google-analytics.com https://*.githubusercontent.com data:; manifest-src 'self'; script-src 'self' https://www.google-analytics.com https://api.github.com; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; base-uri 'self'; frame-ancestors 'self'; report-uri /csp-report
Content-Type: text/html
Date: Mon, 17 Sep 2018 00:44:31 GMT
Server: Werkzeug/0.14.1 Python/2.7.10
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>405 Method Not Allowed</title>
<h1>Method Not Allowed</h1>
<p>The method is not allowed for the requested URL.</p>

Let's try to fix something.

diff --git a/webcompat/__init__.py b/webcompat/__init__.py
index 8bd123f..19927a0 100644
--- a/webcompat/__init__.py
+++ b/webcompat/__init__.py
@@ -28,6 +28,7 @@ limiter = Limiter(app, key_func=get_remote_address)
 
 # import views after we initialize our github object
 import webcompat.views  # nopep8
+import webhooks  # nopep8
 
 # register blueprints
 from api.endpoints import api

Let's redo the HTTP request

→ http POST http://localhost:5000/webhooks/labeler 
HTTP/1.0 401 UNAUTHORIZED
Content-Length: 19
Content-Security-Policy: default-src 'self'; object-src 'none'; connect-src 'self' https://api.github.com; font-src 'self' https://fonts.gstatic.com; img-src 'self' https://webcompat.com https://www.google-analytics.com https://*.githubusercontent.com data:; manifest-src 'self'; script-src 'self' https://www.google-analytics.com https://api.github.com; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; base-uri 'self'; frame-ancestors 'self'; report-uri /csp-report
Content-Type: text/plain
Date: Mon, 17 Sep 2018 01:04:03 GMT
Server: Werkzeug/0.14.1 Python/2.7.10
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block

Nothing to see here

Yeah working.

Let's create a test for this.

→ nosetests
.................................................................................................
----------------------------------------------------------------------
Ran 97 tests in 1.380s

OK

with

diff --git a/tests/unit/test_urls.py b/tests/unit/test_urls.py
index cab3f24..204e226 100644
--- a/tests/unit/test_urls.py
+++ b/tests/unit/test_urls.py
@@ -240,6 +240,16 @@ class TestURLs(unittest.TestCase):
         self.assertTrue('text/html' in rv.content_type)
         self.assertTrue(content_test)
 
+    def test_webhooks_route(self):
+        """Request to /webhooks/labeler should be 401.
+
+        Without identification it sends a 401, and also proves the route exists.
+        """
+        rv = self.app.post('/webhooks/labeler')
+        content_test = 'Nothing to see here' in rv.data
+        self.assertEqual(rv.status_code, 401)
+        self.assertTrue('text/plain' in rv.content_type)
+        self.assertTrue(content_test)
 
 if __name__ == '__main__':
     unittest.main()
diff --git a/webcompat/__init__.py b/webcompat/__init__.py
index 8bd123f..19927a0 100644
--- a/webcompat/__init__.py
+++ b/webcompat/__init__.py
@@ -28,6 +28,7 @@ limiter = Limiter(app, key_func=get_remote_address)
 
 # import views after we initialize our github object
 import webcompat.views  # nopep8
+import webhooks  # nopep8
 
 # register blueprints
 from api.endpoints import api

Let's create a pull request for this.

@karlcow
Copy link
Member

karlcow commented Sep 17, 2018

No need to revert.
@miketaylr pull request done in #2581

karlcow added a commit to karlcow/webcompat.com that referenced this issue Sep 17, 2018
@reinhart1010
Copy link
Author

This one is occuring again, starting from webcompat/web-bugs#19398

@karlcow
Copy link
Member

karlcow commented Oct 6, 2018

@reinhart1010 see #2644

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

No branches or pull requests

2 participants