Skip to content

Commit e493ae2

Browse files
committed
Only respond to valid endpoints on the frontend
Previously, endpoint validity was checked only on the backend. Added a redirect to the 404 page on unknown URLs in general as well.
1 parent 4196a33 commit e493ae2

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

web/server/codechecker_server/routing.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ def is_valid_product_endpoint(uripart):
5252
if uripart in NON_PRODUCT_ENDPOINTS:
5353
return False
5454

55+
# Should be kept in sync with the regex in router/index.js on the frontend.
5556
pattern = r'^[A-Za-z0-9_\-]+$'
5657
if not re.match(pattern, uripart):
5758
return False

web/server/vue-cli/src/router/index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ export default new Router({
4242
component: () => import("@/views/NotFound")
4343
},
4444
{
45-
path: "/:endpoint",
45+
// Should be kept in sync with the regex from is_valid_product_endpoint
46+
// on the backend.
47+
path: "/:endpoint([A-Za-z0-9_-]+)",
4648
meta: {
4749
requiresAuth: true
4850
},
@@ -132,6 +134,10 @@ CheckerCoverageStatistics"),
132134
component: () => import("@/views/SourceComponent")
133135
},
134136
]
137+
},
138+
{
139+
path: "/:unknown(.*)*",
140+
redirect: "/404"
135141
}
136142
]
137143
});

0 commit comments

Comments
 (0)