Skip to content

armgit / ARTEX

Public Imported from GitHub
0

ARTEX - AI autonomous penetration testing system (English translation; upstream: Autumn-27/ARTEX, AGPL-3.0)

fix(web): only http(s) asset URLs become service hrefs

Coff0xcd1431cfdcde0
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 99167e1..2e4b446 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -50,6 +50,7 @@ All notable changes to this project are documented in this file. The format is b
### Fixed
- **Findings CSV formula cells**: `FindingsCSV` prefixes name, class, summary, task, and other text fields that start with `=`, `+`, `-`, `@`, tab, or CR so Excel/LibreOffice do not evaluate them as formulas when the export is opened.
+- **Asset service links**: the Services tab only uses an asset URL as `href` when it is `http:` or `https:`. `javascript:`, `data:`, and other schemes render as text.
- **ask_operator image_path**: the screenshot path must resolve inside the task working directory (`<data>/tasks/<id>`). Absolute paths, `..` segments, and symlinks that leave that directory are refused, so the tool cannot copy an arbitrary server image into the operator transcript.
- **insert_assets fail-closed**: when intercept or task allow/block rules cannot be loaded, `insert_assets` refuses the whole call instead of evaluating an empty rule set (which allowed every asset). The tool result does not include the underlying database error.
- **BlobRange length no longer wraps int64**: `offset+length > size` overflowed when length was near MaxInt64, so the cap was skipped and `make([]byte, length)` could exhaust memory. The bound is now `length > size-offset`.
diff --git a/web/src/app/(main)/function/assets/page.tsx b/web/src/app/(main)/function/assets/page.tsx
index a9abecb..6d70f91 100644
--- a/web/src/app/(main)/function/assets/page.tsx
+++ b/web/src/app/(main)/function/assets/page.tsx
@@ -60,6 +60,7 @@ import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
import { api } from "@/lib/api";
import { parseCompanyScopeText } from "@/lib/company-scope";
+import { httpHref } from "@/lib/http-href";
import type { Asset, Company, CompanyScopeRule } from "@/lib/types";
import { cn } from "@/lib/utils";
@@ -605,10 +606,11 @@ export default function AssetsPage() {
const isHttp = a.service_type === "http";
const svc = a.service_name || (isHttp ? "http" : "") || a.service_type || "";
let domainCell: React.ReactNode = "—";
- if (isHttp && a.url) {
+ const href = isHttp ? httpHref(a.url) : undefined;
+ if (href) {
domainCell = (
<a
- href={a.url}
+ href={href}
target="_blank"
rel="noreferrer"
className="text-blue-600 hover:underline dark:text-blue-400"
@@ -616,8 +618,8 @@ export default function AssetsPage() {
{a.domain || a.url}
</a>
);
- } else if (a.domain) {
- domainCell = a.domain;
+ } else if (a.domain || a.url) {
+ domainCell = a.domain || a.url;
}
return (
<TableRow key={a.id} className={selected.has(a.id) ? "bg-muted/40" : undefined}>
diff --git a/web/src/lib/http-href.test.mjs b/web/src/lib/http-href.test.mjs
new file mode 100644
index 0000000..3c344cf
--- /dev/null
+++ b/web/src/lib/http-href.test.mjs
@@ -0,0 +1,19 @@
+import assert from "node:assert/strict";
+import test from "node:test";
+import { httpHref } from "./http-href.ts";
+
+test("httpHref allows http and https", () => {
+ assert.equal(httpHref("https://example.com/a"), "https://example.com/a");
+ assert.equal(httpHref("http://192.0.2.1:8080/x"), "http://192.0.2.1:8080/x");
+ assert.equal(httpHref(" https://example.com/a "), "https://example.com/a");
+});
+
+test("httpHref refuses javascript, data, and junk", () => {
+ assert.equal(httpHref("javascript:alert(1)"), undefined);
+ assert.equal(httpHref("JAVASCRIPT:alert(1)"), undefined);
+ assert.equal(httpHref("data:text/html,x"), undefined);
+ assert.equal(httpHref("vbscript:x"), undefined);
+ assert.equal(httpHref("/relative"), undefined);
+ assert.equal(httpHref(""), undefined);
+ assert.equal(httpHref(null), undefined);
+});
diff --git a/web/src/lib/http-href.ts b/web/src/lib/http-href.ts
new file mode 100644
index 0000000..c2a5f14
--- /dev/null
+++ b/web/src/lib/http-href.ts
@@ -0,0 +1,18 @@
+// httpHref returns raw when it is an http(s) URL, otherwise undefined.
+// Asset URLs are operator/target-supplied; javascript: and data: must not
+// become href values.
+export function httpHref(raw: string | undefined | null): string | undefined {
+ const s = (raw ?? "").trim();
+ if (!s) {
+ return undefined;
+ }
+ try {
+ const u = new URL(s);
+ if (u.protocol === "http:" || u.protocol === "https:") {
+ return u.href;
+ }
+ } catch {
+ // not a URL
+ }
+ return undefined;
+}