mirror of
https://github.com/laramies/theHarvester.git
synced 2026-08-17 19:35:40 +02:00
fix: serve HarvestView assets locally
This commit is contained in:
@@ -16,11 +16,6 @@ import pytest
|
||||
if TYPE_CHECKING:
|
||||
from playwright.sync_api import Page, Response, Route
|
||||
|
||||
CDNJS_TABULATOR_ASSETS = {
|
||||
'https://cdnjs.cloudflare.com/ajax/libs/tabulator-tables/6.5.2/css/tabulator.min.css',
|
||||
'https://cdnjs.cloudflare.com/ajax/libs/tabulator-tables/6.5.2/js/tabulator.min.js',
|
||||
}
|
||||
|
||||
|
||||
class HarvestViewServer:
|
||||
def __init__(self, repo_root: Path, port: int, environment: dict[str, str], server_log: Path) -> None:
|
||||
@@ -103,9 +98,6 @@ class BrowserFailures:
|
||||
def _guard_request(self, route: Route) -> None:
|
||||
request = route.request
|
||||
parsed = urlsplit(request.url)
|
||||
if request.url in CDNJS_TABULATOR_ASSETS:
|
||||
route.continue_()
|
||||
return
|
||||
if parsed.scheme not in {'http', 'https'} or parsed.hostname == 'localhost':
|
||||
route.continue_()
|
||||
return
|
||||
|
||||
@@ -75,7 +75,7 @@ def test_harvestview_offers_jsonl_and_sqlite_imports_with_jsonl_export(tmp_path,
|
||||
assert 'linkedin-link' not in script.text
|
||||
|
||||
|
||||
def test_harvestview_loads_pinned_tabulator_from_cdnjs(tmp_path, monkeypatch) -> None:
|
||||
def test_harvestview_loads_pinned_tabulator_locally(tmp_path, monkeypatch) -> None:
|
||||
from theHarvester.lib.api import api
|
||||
|
||||
monkeypatch.setenv('THEHARVESTER_API_KEY', 'test-key')
|
||||
@@ -93,20 +93,14 @@ def test_harvestview_loads_pinned_tabulator_from_cdnjs(tmp_path, monkeypatch) ->
|
||||
assert root.status_code == 200
|
||||
assert 'bootstrap.min.css' not in root.text
|
||||
assert 'tabulator_bootstrap5.min.css' not in root.text
|
||||
assert (
|
||||
'<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/tabulator-tables/6.5.2/css/tabulator.min.css" '
|
||||
'integrity="sha512-t8I/asqzdu/MRgVLxVanQ/c5bhUA1qZ/zA432a/3nUh0kkd7P8Qch35wQvTODivf9D6Xv3h7F8p7ezcUyBOQrQ==" '
|
||||
'crossorigin="anonymous" referrerpolicy="no-referrer">'
|
||||
) in root.text
|
||||
assert (
|
||||
'<script src="https://cdnjs.cloudflare.com/ajax/libs/tabulator-tables/6.5.2/js/tabulator.min.js" '
|
||||
'integrity="sha512-AF0YMSgc0Ui4IJPb4hJNSi16wFidZEQa6ZTCAeguF3h5glVnAPuz/JT2ai9ypKhsc9n6CEXBB+tMdxsv1q+rxg==" '
|
||||
'crossorigin="anonymous" referrerpolicy="no-referrer"></script>'
|
||||
) in root.text
|
||||
assert '<link rel="stylesheet" href="/static/harvestview/tabulator.min.css">' in root.text
|
||||
assert '<script src="/static/harvestview/tabulator.min.js"></script>' in root.text
|
||||
assert 'cdnjs.cloudflare.com' not in root.text
|
||||
assert 'https://unpkg.com' not in root.text
|
||||
assert theme.status_code == 404
|
||||
assert script.status_code == 404
|
||||
assert license_file.status_code == 404
|
||||
assert theme.status_code == 200
|
||||
assert 'Tabulator v6.5.2' in script.text
|
||||
assert license_file.status_code == 200
|
||||
assert 'The MIT License (MIT)' in license_file.text
|
||||
assert bootstrap.status_code == 404
|
||||
assert old_theme.status_code == 404
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015-2026 Oli Folkerd
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -6,7 +6,7 @@
|
||||
<meta name="color-scheme" content="light dark">
|
||||
<title>HarvestView</title>
|
||||
<link rel="icon" href="/static/harvestview/logo.webp">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/tabulator-tables/6.5.2/css/tabulator.min.css" integrity="sha512-t8I/asqzdu/MRgVLxVanQ/c5bhUA1qZ/zA432a/3nUh0kkd7P8Qch35wQvTODivf9D6Xv3h7F8p7ezcUyBOQrQ==" crossorigin="anonymous" referrerpolicy="no-referrer">
|
||||
<link rel="stylesheet" href="/static/harvestview/tabulator.min.css">
|
||||
<link rel="stylesheet" href="/static/harvestview/app.css?v={{VERSION}}-{{ASSET_VERSION}}">
|
||||
</head>
|
||||
<body>
|
||||
@@ -348,7 +348,7 @@
|
||||
<div id="toast" class="toast-message" role="status" hidden></div>
|
||||
<div id="announcer" class="sr-only" aria-live="polite"></div>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/tabulator-tables/6.5.2/js/tabulator.min.js" integrity="sha512-AF0YMSgc0Ui4IJPb4hJNSi16wFidZEQa6ZTCAeguF3h5glVnAPuz/JT2ai9ypKhsc9n6CEXBB+tMdxsv1q+rxg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
||||
<script src="/static/harvestview/tabulator.min.js"></script>
|
||||
<script src="/static/harvestview/app.js?v={{VERSION}}-{{ASSET_VERSION}}"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user