diff --git a/app/Http/Controllers/SiteController.php b/app/Http/Controllers/SiteController.php index 4a939764a6..74bafa472c 100644 --- a/app/Http/Controllers/SiteController.php +++ b/app/Http/Controllers/SiteController.php @@ -372,20 +372,10 @@ public function editSite(): View|RedirectResponse ->with('xsl_content', generate_XSLT($xml, base_path() . '/app/cdash/public/editSite', true)); } - public function viewSite(): View + public function viewSite(int $siteid): View { $db = Database::getInstance(); - @$siteid = $_GET['siteid']; - if ($siteid != null) { - $siteid = pdo_real_escape_numeric($siteid); - } - - // Checks - if (!isset($siteid) || !is_numeric($siteid)) { - abort(400, 'Not a valid siteid!'); - } - $site_array = $db->executePreparedSingleRow("SELECT * FROM site WHERE id=?", [$siteid]); $sitename = $site_array['name']; diff --git a/app/cdash/app/Controller/Api/QueryTests.php b/app/cdash/app/Controller/Api/QueryTests.php index 19b12cc07f..8a0ac99538 100644 --- a/app/cdash/app/Controller/Api/QueryTests.php +++ b/app/cdash/app/Controller/Api/QueryTests.php @@ -415,7 +415,7 @@ public function getResponse() $test['labels'] = $row->labelstring; - $siteLink = 'viewSite.php?siteid=' . $row->siteid; + $siteLink = 'sites/' . $row->siteid; $test['siteLink'] = $siteLink; $buildSummaryLink = "build/$buildid"; diff --git a/app/cdash/public/viewMap.xsl b/app/cdash/public/viewMap.xsl index 56ac4bd8a2..f31a71cedf 100644 --- a/app/cdash/public/viewMap.xsl +++ b/app/cdash/public/viewMap.xsl @@ -58,7 +58,7 @@
-viewSite.php?siteid= +sites/
diff --git a/app/cdash/public/views/index.html b/app/cdash/public/views/index.html index f96572ab8e..4820321256 100644 --- a/app/cdash/public/views/index.html +++ b/app/cdash/public/views/index.html @@ -70,7 +70,7 @@
Site: - + {{::cdash.site}} @@ -292,7 +292,7 @@

- + {{::coverage.site}} @@ -413,7 +413,7 @@

- + {{::da.site}} diff --git a/app/cdash/public/views/partials/build.html b/app/cdash/public/views/partials/build.html index ea8e09f7de..bc918eb283 100644 --- a/app/cdash/public/views/partials/build.html +++ b/app/cdash/public/views/partials/build.html @@ -21,7 +21,7 @@ - {{::build.site}} + {{::build.site}} diff --git a/app/cdash/public/views/viewBuildError.html b/app/cdash/public/views/viewBuildError.html index c766d84659..39b9f613ba 100644 --- a/app/cdash/public/views/viewBuildError.html +++ b/app/cdash/public/views/viewBuildError.html @@ -2,7 +2,7 @@ Site: - + {{cdash.build.site}} diff --git a/app/cdash/tests/test_projectwebpage.php b/app/cdash/tests/test_projectwebpage.php index 2c5bc92698..f02e9cb85f 100644 --- a/app/cdash/tests/test_projectwebpage.php +++ b/app/cdash/tests/test_projectwebpage.php @@ -189,7 +189,7 @@ public function testProjectExperimentalLinkMachineName() $buildgroup = array_pop($jsonobj['buildgroups']); $siteid = $buildgroup['builds'][0]['siteid']; - $content = $this->connect($this->url . "/viewSite.php?siteid=$siteid&project=4¤ttime=1235354400"); + $content = $this->connect($this->url . "/sites/$siteid?project=4¤ttime=1235354400"); if (!$content) { return; } elseif (!$this->findString($content, 'Total Physical Memory: 15MiB
')) { diff --git a/app/cdash/tests/test_sitestatistics.php b/app/cdash/tests/test_sitestatistics.php index aaf39fb9a4..931dca1e91 100644 --- a/app/cdash/tests/test_sitestatistics.php +++ b/app/cdash/tests/test_sitestatistics.php @@ -15,9 +15,9 @@ public function __construct() public function testSiteStatistics() { $this->login(); - $content = $this->get($this->url . '/siteStatistics.php'); + $content = $this->get($this->url . '/sites'); if (strpos($content, 'Busy time') === false) { - $this->fail("'Busy time' not found on siteStatistics.php"); + $this->fail("'Busy time' not found on /sites"); } $this->pass('Passed'); } diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index c16c45a70d..6baac120cc 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1288,7 +1288,7 @@ parameters: #^Call to deprecated function pdo_real_escape_numeric\\(\\)\\: 04/01/2023$# """ - count: 5 + count: 4 path: app/Http/Controllers/SiteController.php - @@ -1327,7 +1327,7 @@ parameters: - message: "#^Loose comparison via \"\\!\\=\" is not allowed\\.$#" - count: 4 + count: 3 path: app/Http/Controllers/SiteController.php - diff --git a/resources/js/components/BuildConfigure.vue b/resources/js/components/BuildConfigure.vue index 451b6f4059..70ac358909 100644 --- a/resources/js/components/BuildConfigure.vue +++ b/resources/js/components/BuildConfigure.vue @@ -15,7 +15,7 @@ Site: - + {{ cdash.build.site }} @@ -105,7 +105,7 @@ Site: - + {{ cdash.build.site }} diff --git a/resources/js/components/BuildNotes.vue b/resources/js/components/BuildNotes.vue index 5127e55ec8..38bc0867f3 100644 --- a/resources/js/components/BuildNotes.vue +++ b/resources/js/components/BuildNotes.vue @@ -12,7 +12,7 @@ Site: - + {{ cdash.build.site }} diff --git a/resources/js/components/BuildSummary.vue b/resources/js/components/BuildSummary.vue index a37e9c4f6a..97e117c565 100644 --- a/resources/js/components/BuildSummary.vue +++ b/resources/js/components/BuildSummary.vue @@ -36,7 +36,7 @@ {{ cdash.build.site }} diff --git a/resources/js/components/BuildUpdate.vue b/resources/js/components/BuildUpdate.vue index a4d93d1299..ccd8c43162 100644 --- a/resources/js/components/BuildUpdate.vue +++ b/resources/js/components/BuildUpdate.vue @@ -8,7 +8,7 @@

- Files changed on {{ cdash.build.site }} + Files changed on {{ cdash.build.site }} ({{ cdash.build.buildname }}) as of {{ cdash.build.buildtime }}

diff --git a/resources/js/components/TestDetails.vue b/resources/js/components/TestDetails.vue index b90e696cd9..477074e5bd 100644 --- a/resources/js/components/TestDetails.vue +++ b/resources/js/components/TestDetails.vue @@ -39,7 +39,7 @@ ({{ cdash.test.site }}) diff --git a/resources/views/admin/user.blade.php b/resources/views/admin/user.blade.php index 8f7d772988..26eeed194d 100644 --- a/resources/views/admin/user.blade.php +++ b/resources/views/admin/user.blade.php @@ -364,7 +364,7 @@ - Site Statistics + Site Statistics diff --git a/resources/views/site/site-statistics.blade.php b/resources/views/site/site-statistics.blade.php index f372d999db..3a2474d2ea 100644 --- a/resources/views/site/site-statistics.blade.php +++ b/resources/views/site/site-statistics.blade.php @@ -15,7 +15,7 @@ - + {{ $site->sitename }} diff --git a/resources/views/test/view-test.blade.php b/resources/views/test/view-test.blade.php index 2f95c79a02..e28ef63b96 100644 --- a/resources/views/test/view-test.blade.php +++ b/resources/views/test/view-test.blade.php @@ -25,7 +25,7 @@ Site Name: - {{::cdash.build.site}} diff --git a/routes/web.php b/routes/web.php index cc024c7205..228ea34eab 100755 --- a/routes/web.php +++ b/routes/web.php @@ -164,7 +164,11 @@ // TODO: (williamjallen) Replace this /ajax route with an equivalent /api route Route::get('/ajax/getsubprojectdependencies.php', 'SubProjectController@ajaxDependenciesGraph'); -Route::get('/viewSite.php', 'SiteController@viewSite'); +Route::match(['get', 'post'], '/sites/{siteid}', 'SiteController@viewSite')->whereNumber('siteid'); +Route::get('/viewSite.php', function (Request $request) { + $siteid = $request->query('siteid'); + return redirect("/sites/$siteid", 301); +}); Route::get('/viewMap.php', 'MapController@viewMap'); @@ -221,7 +225,10 @@ Route::get('/removeBuilds.php', 'AdminController@removeBuilds'); Route::post('/removeBuilds.php', 'AdminController@removeBuilds'); - Route::get('/siteStatistics.php', 'SiteController@siteStatistics'); + // TODO: (williamjallen) Move this out of the admin-only section, and instead query only + // the sites a given user is able to see. + Route::get('/sites', 'SiteController@siteStatistics'); + Route::permanentRedirect('/siteStatistics.php', '/sites'); Route::get('/manageUsers.php', 'ManageUsersController@showPage'); Route::post('/manageUsers.php', 'ManageUsersController@showPage'); diff --git a/tests/Feature/RouteAccessTest.php b/tests/Feature/RouteAccessTest.php index 4a02696e7c..db83556014 100644 --- a/tests/Feature/RouteAccessTest.php +++ b/tests/Feature/RouteAccessTest.php @@ -68,7 +68,7 @@ private function adminRoutes(): array return [ ['/upgrade.php'], ['/removeBuilds.php'], - ['/siteStatistics.php'], + ['/sites'], ['/manageUsers.php'], ['/monitor'], ['/ajax/findusers.php'], diff --git a/tests/Spec/build-summary.spec.js b/tests/Spec/build-summary.spec.js index 865991b436..9fa1fad3ff 100644 --- a/tests/Spec/build-summary.spec.js +++ b/tests/Spec/build-summary.spec.js @@ -101,7 +101,7 @@ test('BuildSummary handles API response', async () => { expect(html).toContain('mysite'); expect(html).toContain('Linux'); const site_link = component.find('#site_link'); - expect(site_link.attributes('href')).toMatch('/viewSite.php?siteid=1'); + expect(site_link.attributes('href')).toMatch('/sites/1'); expect(site_link.text()).toBe('mysite'); const configure_link = component.find('#configure_link'); diff --git a/tests/Spec/test-details.spec.js b/tests/Spec/test-details.spec.js index 9b6402bd2f..dfeced241f 100644 --- a/tests/Spec/test-details.spec.js +++ b/tests/Spec/test-details.spec.js @@ -146,7 +146,7 @@ lines`); const site_link = component.find('#site_link'); expect(site_link.text()).toBe('(my site)'); - expect(site_link.attributes('href')).toMatch('/viewSite.php?siteid=1'); + expect(site_link.attributes('href')).toMatch('/sites/1'); const revision_link = component.find('#revision_link'); expect(revision_link.text()).toBe('asdf');