Repository navigation
test(frontend): cover the theme mode state machine in the app store - #346
Closed
NightGlowww wants to merge 68 commits into
Closed
NightGlowww wants to merge 68 commits into
NightGlowww wants to merge 68 commits into
Conversation
NewService never set urlService, so creating a task whose targets come from UrlScan (search or select) called a method on a nil interface and the server panicked in Insert.
…panic Upstream PR by ganeshmshetty; adds regression test asserting NewService wires every dependency. Fixes Autumn-27#342 (part 2).
cmd/main/basic_usage.go declared a second main() in package main, so go build ./... and every release build failed with "main redeclared". Guard the example with //go:build example and gate the new urlService regression test behind //go:build integration (it needs a live Mongo).
Upstream PR by Arrnitage: namespace, Mongo StatefulSet, Redis, server and scan deployments, services and secrets, plus a single-file all.yml bundle.
Upstream PR by chlwotjd66: full ko-KR catalogue, Element Plus locale mapping, locale-parity scripts, README_KR and docs.
…m following
- 新增 themeMode(auto|light|dark),默认 auto 跟随设备 prefers-color-scheme;systemDark 变化时仅 auto 模式实时应用
- 顶栏/登录页/设置抽屉统一使用 ThemeSwitch 三态下拉(日间/夜间/跟随系统),当前项带勾选
- index.html 首屏内联脚本预置 dark/light 类与 color-scheme,避免闪烁;兼容 useStorage 的 {type,value} 包装与旧版 isDark 键迁移
- ECharts 主题切换时 dispose 后以 dark 主题重建实例;新增 styles/dark.less 收口历史写死浅色面
- 补 en/zh-CN/ko-KR 文案(三方 863 键对齐),新增 pnpm theme:check 自检脚本与 docs/theme-dark-mode.md
GetLogs always used LRange, so a plugin log key written by an older release as a Redis set made "view plugin log" fail with "WRONGTYPE Operation against a key holding the wrong kind of value". Check TYPE first: list keeps insertion order, set is read with SMembers and sorted for stable output, missing key returns empty text, other types return an explicit error instead of an opaque Redis one. Refs Autumn-27#290
POST /api/task/template/delete was registered without any middleware, so an unauthenticated caller could delete scan templates. Add WithAuth and ship an AST-based route audit test that fails when any route outside the login allowlist is registered without WithAuth/WithAuthAndPermission. Refs Autumn-27#295
Tasks were written with status=1 (running) the moment they were inserted, so a scheduled run that no node had picked up yet showed up as 运行中 in the task list with 0% progress. Introduce an explicit pending status (0), insert tasks as pending, poll pending+running tasks for progress and promote to running only once progress appears. Node re-registration (checkNodeTask) now also re-queues pending tasks, otherwise a pending task could never be dispatched. Refs Autumn-27#288
logger.Error(fmt.Sprintf("TemplateDetail error", err)) had no %v verb, so the error
was rendered as %!EXTRA and go vet failed the package with "fmt.Sprintf call has
arguments but no formatting directives". The literal "Failed to get CPU usage" call
from the report lives in the ScopeSentry-Scan repo; this is the same defect inside
this repo.
Refs Autumn-27#330
- 校验方法:PyYAML 解析、kubectl(无集群时的实际行为)、kubeconform -strict - 一致性核查:secretKeyRef/selector/serviceName/镜像 tag/NodePort - 部署顺序、Secret 填写、镜像 tag 升级、服务暴露、env 对照表 - 已知问题分三档:1 个阻断(volumeClaimTemplates 缩进错位)、13 项建议、7 项可接受 - 核查 scan 端 NodeName/TimeZoneName:以 README_CN 与代码为准
…ctually created StatefulSet had volumeClaimTemplates at the document root, so the template was dropped: no PVC was created, volumeMount pointed at a non-existent volume and Mongo could never become ready. kubeconform -strict goes 18/20 -> 20/20 valid. k8s/README.md records the fix.
…ws pending (#225 Autumn-27#288) - exportData.vue defaulted to filetype=csv while the backend only accepts xlsx/json, so every export failed with 400; default and radio label are now xlsx and the backend message matches - Task list maps status 0 to 待开始/Pending/시작 대기 so scheduled tasks no longer render 运行中 before they start - en/zh-CN/ko-KR stay in parity (864 keys)
…Safari - 旧版 isDark 不再迁移为 light/dark:旧代码按系统状态覆写它,迁移会把升级用户钉死在非 auto;首屏脚本同步改为只认 themeMode - initTheme 增加 window 守卫,useStorage.getStorage 增加 try/catch(隐私模式/损坏值不再导致根组件 setup 白屏) - MediaQueryList 兼容旧 Safari 的 addListener/removeListener,绑定前统一解绑 - EChart 卸载时 dispose,避免骨架屏替换/路由切换泄漏 canvas 与 ResizeObserver - check-theme.ts 改为行为断言(真实调用 resolveInitialThemeMode/resolveIsDark/applyThemeClass + 假 DOM),48 项全部 PASS;源码字符串检查降级为 smoke - frontend/.gitignore 修正引用式写法并忽略 pnpm-lock.yaml
The task list button POSTs /api/task/sync, but no such route or handler existed, so it always 404'd. Add the endpoint: it collects the selected tasks' targets (trimmed, de-duplicated, empty set rejected), then either merges them into an existing project's target or creates a new project from name/tag, and recomputes the project asset association synchronously. Refs Autumn-27#317
Static contract test for common.Insert's target-source chain: each *Source value must be paired with a TargetTp comparison, and both search/select modes must exist. The reported "UrlScan branch ignores TargetTp" does not reproduce on HEAD (line 112 already guards targetTp==search like asset/RootDomain/subdomain); this test locks that invariant so the regression the report describes cannot appear silently. Refs Autumn-27#317
…utumn-27#317 Autumn-27#330) and route audit tests
- 主题切换加 240ms 全局颜色过渡(reduced-motion 下关闭),设置面板改为三段式分段控件,顶栏入口改为真按钮并带动态 aria-label/提示(主题模式:夜间模式) - 滚动条/选中文本/键盘 focus-visible 描边统一跟随主题变量;顶栏 .custom-hover 补统一 hover 反馈;index.html 增加 color-scheme meta,原生控件首屏即按主题渲染 - Monaco 差异/指纹编辑器跟随 vs/vs-dark,CodeMirror POC 编辑器深色才挂 oneDark,并移除写死的 #1e1e1e 背景;EChart 卸载 dispose - docs/theme-dark-mode.md 增加 UI/UX 细节表与最新截图(深色/浅色/设置面板)
Adds Autumn-27#330 Autumn-27#290 Autumn-27#295 Autumn-27#288 Autumn-27#317 #225 to 本次已修复 and marks Autumn-27#262 as blocked on scan-node signals.
feat: 三态主题 + 修复上游 PR/issue(#225 Autumn-27#288 Autumn-27#290 Autumn-27#295 Autumn-27#317 Autumn-27#330)
- 新增设计 token(app-primary #2f6feb / 中性面 / 6-14px 圆角 / 克制阴影 / 系统字体 / 56px 顶栏 / 42px 标签页)与 styles/modern.less 组件层重绘 - Element Plus 覆盖统一加 html 前缀,解决按需 CSS chunk 晚于 index.css 加载导致的同特异度失效(卡片圆角/表头底色此前被覆盖回 4px 与白色) - 侧边栏与标签页改为 pill:选中态 primary@10% + 主色文字;表头 12px 次级色 + surface-2 底色;按钮/输入框 34px 高 8px 圆角;弹层 14px 圆角 - 登录页重做为深色品牌墙 + 表单卡片;首页指标卡改为色块图标 + 26px 数字;设置按钮与抽屉细节统一 - 31 处视图写死的表头色改为 --app-surface-2;修正 /api/assets/statistics 的前端返回类型;清理 LoginForm 未用代码与表单内标题 - 新增 docs/ui-modernization.md 与 docs/images/ui 截图;README_CN 功能列表补充
feat(ui): 主题跨标签同步 / 登录兜底 / 方角收口 / 拆包提速
…tors Backend: new internal/api/middleware/compress (leaf package, no DB init) — gzip for JS/CSS/HTML/JSON/SVG with Vary/Accept-Encoding, skipping HEAD/Range/Upgrade/mcp and binary types; Cache-Control immutable(1y) for /assets/*, no-cache for html, 1h for other statics. Live check: 1.74MB app.js -> 524KB (70% off), login JSON gzipped. Frontend: Monaco diff editor is now an async component loaded only when the Body Diff dialog opens, monaco itself is dynamically imported; xgplayer is dynamically imported by VideoPlayer. Asset page JS payload 2361KB -> 1309KB, monaco/xgplayer no longer on first paint, DCL 376ms -> 185ms. Tests: compress_test.go covers immutable assets, no-cache html, gzip JSON, and skip rules for HEAD/Range/no-Accept-Encoding.
perf: gzip + 静态长缓存 + 重型依赖懒加载
ci: self-hosted CI on dev-tx-sh-app-01
Uploading the whole Go module cache to the Actions cache took minutes and adds nothing here: ~/go/pkg/mod persists on the runner. Keep the module cache warm on disk instead.
ci: 关闭 setup-go 的 Actions 缓存
…conventions - Makefile: help/build/binary/test-hermetic/vet/fmt/fmt-check/mod-check/frontend-*/ci,本地一条命令复现 CI 门禁 - CI: 新增 gofmt 与 go mod tidy 漂移两道阻塞闸;保留 goproxy.cn 与 setup-go 无缓存策略 - 新增 GET /healthz(ping Mongo+Redis,异常 503),叶子包 + 4 项单测;k8s deployment 的 readiness/liveness 指向它 - 仓库规范:.editorconfig、.gitattributes(LF/binary)、PR 模板、Dependabot(gomod/npm/actions)、docs/engineering.md - 全仓 gofmt(14 个历史未格式化文件) - UI 收口:标签页改纸片式(浅底、无边框、选中用阴影,删除 dark 覆盖残留)、节点页工具栏去掉空行、语义色按钮统一柔和着色、徽标不压按钮圆角
The pnpm store persists at ~/.local/share/pnpm/store on the runner. Uploading it to Actions cache is slow and its post step can be cancelled (which marks the job failed even when every real step passed). Install with --prefer-offline instead.
chore(eng): Makefile / CI 质量门禁 / healthz / 仓库规范
… hook - new integration job: ephemeral mongo:7.0.28 + redis:7.0.11 on random ports, warm up an empty DB once, then run go test ./...; cleanup always - hermetic job now emits coverage.out and uploads the go-coverage artifact - .githooks/pre-commit checks staged Go files with gofmt (opt-in: git config core.hooksPath .githooks) - fix the four remaining vet errors that blocked go test ./...: non-constant format strings (notification x2, ct sdk) and int->string conversion in GetMongoURI - Makefile: test-integration; docs updated
- eslint --fix over src: 74 formatting errors fixed (prettier rules), no logic changes - rename shadowed v-for index variables (AssetInfo2 / SensitiveInformation / AssetDetail2) to clear the 5 remaining warnings - CI frontend job now runs eslint --max-warnings 0 as a blocking step
ci: Mongo/Redis 集成测试 / 覆盖率产物 / pre-commit hook
…216 Autumn-27#340) Search (#216): a bare token (e.g. typing a domain) used to be dropped, so the query returned everything or failed with "insufficient operands for &&". It now expands to a case-insensitive $or over identity fields (host/rootDomain/ip/url/title/vulname/service/technologies/tags/type/taskName); regex metacharacters are escaped and body/rawheaders/metadata stay out so a single word cannot trigger a full-collection scan over large text. Also reject a dangling operator and a stack with leftover clauses instead of silently using the first one. Fingerprints (Autumn-27#340): one-click update matched only on fingerprint_id, while Add() generated a random SAA_ id, so every update inserted a second row with the same name. The upsert now checks fingerprint_id first, then falls back to the same-name legacy row and backfills fingerprint_id; Add() updates the existing same-name row instead of inserting. New indexes on fingerprint_id (sparse) and name. Tests: 7 search cases (bare term, escaping, &&/||, dangling operator, unknown index) + 4 dedupe decision cases + 1 integration test that seeds a legacy row against real Mongo and asserts exactly one row remains with the upstream id. CI: the integration job and make test-integration now run with -tags integration, so DB-backed end-to-end cases are covered.
… cannot crash on startup Cold start on an empty database races: one process creates the DB, another sees it as existing and then fails on the missing timezone config, which log.Fatalf kills the test binary (integration job failed on internal/services/task/common). timezone seeding is now an upsert, and the already-exists branch seeds the default instead of returning an error. Verified with -tags integration on a freshly dropped database: all packages ok. CI: warmup now runs internal/services/task/common (a package that actually initialises the DB) instead of project.
…dupe fix: 裸词搜索 + 指纹判重(#216 Autumn-27#340)
…ped clearing (#228 #232 #242) #228: target parsing duplicated in three places and never prefixed company names, so "腾讯科技" landed in rootDomains as-is and never matched assets. New BuildRootDomains() normalizes: blank lines dropped, company names get CMP:, ICP numbers get ICP: and lose their -N site suffix, order-preserving dedupe. All three call sites now use it. #232: every domain used to be concatenated into one big ICP regex. Domains now match with $in, only ICP values go through regex, and those are chunked at 50 per clause; projects without ICP entries produce no regex at all. #242: the clear step matched on "project exists" instead of "project == this project", so updating project A wiped associations of project B. Both the clear queries and the builders now carry projectID. Tests: 6 BuildRootDomains cases, 5 query-shape cases (project scoping, no regex without ICP, chunking, escaping, dedupe) and one integration test that seeds two projects in real Mongo and asserts the untouched one keeps its association.
…BuildRootDomains Follow-up to #228: prefixing every unparsable target with CMP: broke intranet-style single-label hosts (intranet -> CMP:intranet) and the char-set check accidentally contained a literal t. Only prefix CMP: when the token contains CJK characters or separators that never appear in hostnames; keep single-label ASCII hosts as-is; *.example.com maps to its root domain so it can match asset rootDomain values. Tests: 8 cases now, including single-label host and wildcard mapping.
fix(project): 单 label 主机与通配符在 BuildRootDomains 里被误处理
…Autumn-27#254) The node list parsed the node-reported local timestamp in the server timezone and compared it with time.Now(). A node running in UTC (or with a slightly fast clock) produced an 8-hour or negative difference, so it was marked offline and its Redis state was overwritten with 3 — the node then stayed offline in the UI. New ClassifyLiveness interprets the same string in both the server timezone and UTC, keeps whichever is closest to server time, treats a small negative difference as clock skew instead of death, and keeps the node when the timestamp is unparsable. The timeout window is configurable via NODE_TIMEOUT_SECONDS (default 300s, unchanged). Per-node Info logging on every poll is now Debug. Tests: 7 unit cases (fresh, stale, timezone mismatch, clock ahead, unparsable, non-running states, env override) plus 2 Redis-backed integration cases that seed node:it-node-utc and assert the repository round-trips it. Triage: #169 recorded as belonging to ScopeSentry-Scan (vulnerabilities are written by the node, the server only reads), with the evidence.
fix(node): 节点不再因时区/时钟差异被误判离线(Autumn-27#254)
The frontend only had static self-check scripts; logic that already caused regressions (storage robustness, theme mode resolution) had no unit tests. Adds vitest 1.6 + jsdom, a config with the @ alias, and a setup file that installs an in-memory Storage when Node 26 shadows jsdom localStorage (its experimental global is unavailable without --localstorage-file). The polyfill exposes keys as own properties because useStorage.clear() relies on Object.keys(localStorage). 16 tests: useStorage round-trip / raw JSON / corrupted JSON / throwing backend / missing key / clear with excludes; theme mode validation, no legacy isDark migration, dark resolution, applyThemeClass; is/isEmpty/isUrl/isImgPath. CI frontend job runs pnpm test; Makefile gains frontend-test and frontend-check now includes it.
test(frontend): 引入 vitest 单测并接入 CI
…g CI gate
Full-repo vet had 144 diagnostics: 141 unkeyed bson.E literals, 2 discarded fmt.Errorf results, 1 discarded context.CancelFunc. Unkeyed literals are silently reorderable, the dropped errors hid index-creation failures, and the cancel leak kept contexts alive.
bson.D literals were rewritten with an AST tool (bson.D{{"k", v}} -> bson.D{{Key: v, Value: v}}), including elided-type stages inside mongo.Pipeline. The two index errors now log, and worker.Run defers its cancel.
New regression test asserts every stage key of buildAggregatePipeline plus the $match payload, skip/limit values and $group _id, so a literal rewrite cannot silently reorder or drop a stage.
CI and make vet now run go vet ./... instead of four hand-picked packages.
chore(vet): 清空 144 条 vet 告警并把全仓 vet 设为阻塞闸
…are and databases Covers the login chain that the frontend depends on: /healthz 200, an unauthenticated call to a protected route returns 401, POST /api/user/login returns an access_token for a seeded super_admin, and the same call with that token returns 200 with assetCount. Runs under -tags integration so the existing Integration job exercises it against ephemeral Mongo/Redis; no browser needed.
test(api): 真实路由 + 数据库的端到端冒烟(登录链路)
- 新增 9 条行为用例:跨标签 storage 同步(含损坏值)、启动恢复持久化模式、 旧版 isDark 不迁移、三态切换时 state/localStorage/html class/color-scheme 一致、 仅 auto 跟随系统、同模式不重复写盘、手动切换的一次性过渡、prefers-reduced-motion、 以及缺少 matchMedia 的环境不崩 - playThemeTransition 对 matchMedia 结果补可选链,老 WebView 下不再抛错
Author
|
Opened on the wrong repo by mistake; tracked in the fork NightGlowww/ScopeSentry. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
主题三态(auto/light/dark)之前只有纯函数单测,Store 里的状态机没有覆盖——
真正会出问题的正是这一段:写盘、落地 class、跟随系统、跨标签同步。
本 PR 补 9 条行为级用例(jsdom + pinia,无需浏览器):
顺手加固:`playThemeTransition` 里 `window.matchMedia?.(...).matches` 的返回值也补可选链,
缺少 matchMedia 时不再 TypeError(与 `bindSystemThemeListener` 的守卫保持一致)。
变异验证:把「仅 auto 跟随系统」的守卫改成 `if (true)`,该用例立刻变红(已还原)。
验证