@cobola/dsh-geo 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/publish.yml +59 -0
- package/CHANGELOG.md +27 -0
- package/CONTRIBUTING.md +86 -0
- package/LICENSE +176 -0
- package/NOTICE +14 -0
- package/README.md +194 -2
- package/SECURITY.md +46 -0
- package/bin/dsh-geo.js +378 -0
- package/client.js +695 -0
- package/cordis.patch.yml +4 -0
- package/docs/CI.md +118 -0
- package/docs/GOOGLE.md +57 -0
- package/docs/NPM-TRUSTED-PUBLISHING.md +69 -0
- package/docs/PROFILES.md +40 -0
- package/docs/RULES.md +108 -0
- package/icon.svg +8 -0
- package/index.js +376 -0
- package/lib/audit.js +62 -0
- package/lib/fetch.js +650 -0
- package/lib/html.js +649 -0
- package/lib/profiles.js +62 -0
- package/lib/report.js +353 -0
- package/lib/robots.js +198 -0
- package/lib/rules.js +939 -0
- package/lib/scan.js +602 -0
- package/lib/score.js +143 -0
- package/lib/store.js +277 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +66 -4
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
name: Publish to npm
|
|
2
|
+
run-name: Publish ${{ github.ref_name }} to npm
|
|
3
|
+
|
|
4
|
+
on:
|
|
5
|
+
push:
|
|
6
|
+
tags:
|
|
7
|
+
- 'v*'
|
|
8
|
+
|
|
9
|
+
permissions:
|
|
10
|
+
contents: read
|
|
11
|
+
id-token: write
|
|
12
|
+
|
|
13
|
+
concurrency:
|
|
14
|
+
group: npm-publish-${{ github.ref }}
|
|
15
|
+
cancel-in-progress: false
|
|
16
|
+
|
|
17
|
+
jobs:
|
|
18
|
+
verify-and-publish:
|
|
19
|
+
if: github.repository == 'cobola/dsh-geo'
|
|
20
|
+
runs-on: ubuntu-latest
|
|
21
|
+
steps:
|
|
22
|
+
- name: Check out source
|
|
23
|
+
uses: actions/checkout@v4
|
|
24
|
+
|
|
25
|
+
- name: Set up Node.js
|
|
26
|
+
uses: actions/setup-node@v4
|
|
27
|
+
with:
|
|
28
|
+
node-version: 24
|
|
29
|
+
registry-url: https://registry.npmjs.org
|
|
30
|
+
cache: npm
|
|
31
|
+
|
|
32
|
+
- name: Ensure npm supports trusted publishing
|
|
33
|
+
run: npm install --global npm@latest
|
|
34
|
+
|
|
35
|
+
- name: Install dependencies
|
|
36
|
+
run: npm ci
|
|
37
|
+
|
|
38
|
+
- name: Run tests
|
|
39
|
+
run: npm test
|
|
40
|
+
|
|
41
|
+
- name: Verify generated rule documentation
|
|
42
|
+
run: |
|
|
43
|
+
npm run docs
|
|
44
|
+
git diff --exit-code -- docs/RULES.md
|
|
45
|
+
|
|
46
|
+
- name: Check package contents
|
|
47
|
+
run: npm pack --dry-run
|
|
48
|
+
|
|
49
|
+
- name: Verify tag matches package version
|
|
50
|
+
run: |
|
|
51
|
+
PACKAGE_VERSION=$(node -p "require('./package.json').version")
|
|
52
|
+
TAG_VERSION="${GITHUB_REF_NAME#v}"
|
|
53
|
+
test "$PACKAGE_VERSION" = "$TAG_VERSION" || {
|
|
54
|
+
echo "Tag $GITHUB_REF_NAME does not match package version $PACKAGE_VERSION" >&2
|
|
55
|
+
exit 1
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
- name: Publish with npm Trusted Publishing
|
|
59
|
+
run: npm publish --access public
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.2.0 - 2026-11-29
|
|
4
|
+
|
|
5
|
+
- Published as the scoped npm package `@cobola/dsh-geo` (the unscoped `dsh-geo` name was refused by npm for being too similar to `d3-geo`).
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
- Add DSH `geo_scan` and `geo_fix_plan` tools.
|
|
10
|
+
- Add local `.dsh-geo/` reports, bounded history, scan diffs, and fix plans.
|
|
11
|
+
- Add the Website Visibility Audit settings section and the Visibility Dashboard.
|
|
12
|
+
- Add CLI commands for `scan`, `fix-plan`, `history`, and `diff`.
|
|
13
|
+
- Add CI threshold support with `--fail-under`.
|
|
14
|
+
- Add Google-aligned Core and Google evidence boundaries, with source-mapped
|
|
15
|
+
Bing, Baidu, OpenAI, and Perplexity profile planning.
|
|
16
|
+
|
|
17
|
+
### Security
|
|
18
|
+
|
|
19
|
+
- Add SSRF protection, DNS/IP validation, direct connections, metadata blocking,
|
|
20
|
+
redirect validation, robots.txt enforcement, rate limits, size limits, and
|
|
21
|
+
workspace-local report writes.
|
|
22
|
+
|
|
23
|
+
### Documentation
|
|
24
|
+
|
|
25
|
+
- Add Apache-2.0 licensing, security policy, contribution guide, CI guide,
|
|
26
|
+
Google guidance mapping, and platform profile boundaries.
|
|
27
|
+
- Rewrite product copy around a read-only, reproducible website visibility audit.
|
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# Contributing to dsh-geo
|
|
2
|
+
|
|
3
|
+
Thank you for helping improve the project.
|
|
4
|
+
|
|
5
|
+
## Before you start
|
|
6
|
+
|
|
7
|
+
`dsh-geo` is a local-first, read-only website visibility audit. It scans a
|
|
8
|
+
public URL, returns reproducible evidence and a prioritized fix plan, and never
|
|
9
|
+
edits the audited site. It is not a ranking database, traffic analytics product,
|
|
10
|
+
or guarantee of AI citations.
|
|
11
|
+
|
|
12
|
+
Please open an issue before large changes. Small bug fixes, fixture additions,
|
|
13
|
+
documentation improvements, and source-backed rule improvements are welcome.
|
|
14
|
+
|
|
15
|
+
## Development setup
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
npm install
|
|
19
|
+
npm test
|
|
20
|
+
npm run docs
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
The project targets Node.js 22 and DeepSeek Harness 0.2.2-rc.5 or later within
|
|
24
|
+
the declared engine range. It has no build step; the browser half is the DSH
|
|
25
|
+
lazy-module format in `client.js`.
|
|
26
|
+
|
|
27
|
+
## Adding or changing a rule
|
|
28
|
+
|
|
29
|
+
Rules live in `lib/rules.js` and are deterministic functions of the scan
|
|
30
|
+
artifact plus the explicit reference time. A rule contribution must include:
|
|
31
|
+
|
|
32
|
+
- a stable rule id;
|
|
33
|
+
- one of the five existing dimensions;
|
|
34
|
+
- a positive weight and a clear title;
|
|
35
|
+
- an evidence string that explains the observed fact;
|
|
36
|
+
- an actionable, white-hat fix;
|
|
37
|
+
- a verification condition that a later scan can observe;
|
|
38
|
+
- tests covering pass, fail, warn, or skip behavior as appropriate;
|
|
39
|
+
- a source link when the rule claims to represent a platform requirement.
|
|
40
|
+
|
|
41
|
+
Do not add a rule based only on an undocumented GEO tactic. If a platform has
|
|
42
|
+
not publicly documented a behavior, label the check as advisory or experimental
|
|
43
|
+
and keep it out of the Core score. See `docs/GOOGLE.md` and `docs/PROFILES.md`.
|
|
44
|
+
|
|
45
|
+
After changing the rule table:
|
|
46
|
+
|
|
47
|
+
```sh
|
|
48
|
+
npm run docs
|
|
49
|
+
npm test
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
`docs/RULES.md` is generated; do not edit it by hand.
|
|
53
|
+
|
|
54
|
+
## Fixtures and security tests
|
|
55
|
+
|
|
56
|
+
Use `test/fixtures/` for reproducible sites. Keep fixtures self-contained and
|
|
57
|
+
free of credentials. Add SSRF, redirect, robots, size, timeout, parser, and
|
|
58
|
+
workspace-path tests when changing those boundaries. Never point tests at a
|
|
59
|
+
third-party private address.
|
|
60
|
+
|
|
61
|
+
## Product copy
|
|
62
|
+
|
|
63
|
+
Copy should describe the user outcome first: a site can be discovered,
|
|
64
|
+
understood, and cited more reliably. Avoid promises about rankings, traffic, or
|
|
65
|
+
AI citations. Keep the distinction between a structural audit and platform
|
|
66
|
+
analytics explicit.
|
|
67
|
+
|
|
68
|
+
## Pull requests
|
|
69
|
+
|
|
70
|
+
A useful pull request includes:
|
|
71
|
+
|
|
72
|
+
- the problem and user impact;
|
|
73
|
+
- the files changed;
|
|
74
|
+
- tests run and their output;
|
|
75
|
+
- any change to baseline scores;
|
|
76
|
+
- source links for platform-specific claims;
|
|
77
|
+
- security and privacy implications;
|
|
78
|
+
- documentation updates.
|
|
79
|
+
|
|
80
|
+
Please do not commit real `.dsh-geo/` reports, generated package tarballs,
|
|
81
|
+
private URLs, credentials, or machine-specific profile files.
|
|
82
|
+
|
|
83
|
+
## License
|
|
84
|
+
|
|
85
|
+
By contributing, you agree that your contribution is licensed under the
|
|
86
|
+
Apache License, Version 2.0, as described in `LICENSE`.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
package/NOTICE
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
dsh-geo
|
|
2
|
+
|
|
3
|
+
Copyright 2026 dsh-geo contributors.
|
|
4
|
+
|
|
5
|
+
This project is licensed under the Apache License, Version 2.0. See LICENSE for
|
|
6
|
+
full license text.
|
|
7
|
+
|
|
8
|
+
The project name and logo are not granted as trademarks by the Apache License.
|
|
9
|
+
Third-party names, logos, documentation, and service marks remain the property
|
|
10
|
+
of their respective owners.
|
|
11
|
+
|
|
12
|
+
The project does not claim affiliation with Google, Microsoft, Baidu, OpenAI,
|
|
13
|
+
Anthropic, Perplexity, or DeepSeek. References to their public documentation
|
|
14
|
+
identify source material only.
|
package/README.md
CHANGED
|
@@ -1,3 +1,195 @@
|
|
|
1
|
-
#
|
|
1
|
+
# dsh-geo
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**让网站更容易被搜索系统发现、理解和引用。**
|
|
4
|
+
|
|
5
|
+
> Apache-2.0 开源项目 · 当前版本 v0.2.0 · npm / 本地目录安装 · 不上传站点内容
|
|
6
|
+
|
|
7
|
+
`dsh-geo` 是一个面向网站维护者、内容团队、SEO/GEO 顾问和开发者的只读、可复现网站可见性体检工具。
|
|
8
|
+
|
|
9
|
+
`dsh-geo` 是一个只读、可复现的网站 GEO/SEO 结构体检工具:它读取网站实际返回的 HTML、robots.txt、sitemap 和结构化数据,找出影响可见性的具体问题,生成可以直接执行的修复清单,并在修改后用同一套规则复查结果。
|
|
10
|
+
|
|
11
|
+
它适合维护官网、内容站、文档站和数据产品的产品负责人、内容负责人、SEO/GEO 顾问与开发者。工具不承诺排名,也不猜测任何平台的黑盒算法;它只报告能够从网站和公开平台文档中验证的事实。
|
|
12
|
+
|
|
13
|
+
## 现在能做什么
|
|
14
|
+
|
|
15
|
+
| 入口 | 能力 |
|
|
16
|
+
|---|---|
|
|
17
|
+
| `geo_scan`(DSH 工具) | 抓取并评分一个站点,报告写入 `.dsh-geo/`,自动与上次扫描对比 |
|
|
18
|
+
| `geo_fix_plan`(DSH 工具) | 把最近一次(或指定的)报告变成按影响力排序的修复清单 |
|
|
19
|
+
| **设置 → GEO 体检**(面板) | 修改抓取页数、robots 策略、限速、超时、体积上限、报告目录、私有目标开关 |
|
|
20
|
+
| CLI(`dsh-geo`) | `scan` / `fix-plan` / `history` / `diff`,支持 `--json` 与 `--fail-under`,可直接进 CI |
|
|
21
|
+
|
|
22
|
+
报告固定在会话工作区的 `.dsh-geo/` 下;报告可能包含页面正文摘录,上传 CI artifact 前请先审阅内容:
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
.dsh-geo/
|
|
26
|
+
latest.json 最近一次完整产物(scan + score + diff)
|
|
27
|
+
history/<scannedAt>.json 每次扫描一份,保留最近 50 份
|
|
28
|
+
report.md 给人看的体检摘要
|
|
29
|
+
fix-plan.md / fix-plan.json 最新修复清单(机器可读 + Markdown)
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
相同站点、配置、规则版本和参考时间(`--now` / 工具参数 `now`)→ 可复现的产物与分数,因此复扫结果可以归因到代码改动。
|
|
33
|
+
|
|
34
|
+
## 安装
|
|
35
|
+
|
|
36
|
+
从 npm 安装(命令行):
|
|
37
|
+
|
|
38
|
+
```sh
|
|
39
|
+
npm install -g @cobola/dsh-geo
|
|
40
|
+
dsh-geo --version
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
作为 DSH 插件使用,推荐从本地目录链接安装:
|
|
44
|
+
|
|
45
|
+
```sh
|
|
46
|
+
git clone https://github.com/cobola/dsh-geo.git
|
|
47
|
+
cd dsh-geo
|
|
48
|
+
npm install # 安装唯一的运行时依赖 @deepseek-ai/schemastery
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
然后在 DSH 里二选一:
|
|
52
|
+
|
|
53
|
+
- **Plugins → Add plugin**,选择这个目录;
|
|
54
|
+
- 或用 `plugin_manager` 的 `install_bundle`,`target` 填该目录的绝对路径。
|
|
55
|
+
|
|
56
|
+
安装后:
|
|
57
|
+
|
|
58
|
+
1. 在**设置 → 网站可见性体检**里确认默认值(尤其“允许本机/私网目标”,默认关闭);
|
|
59
|
+
2. 新开一个会话,让 agent 跑一次 `geo_scan`;
|
|
60
|
+
3. 首次安装显示成功但工具没出现时,重启 DSH(替换已安装的 JS 需要重启加载新模块)。
|
|
61
|
+
|
|
62
|
+
## 最快上手:从扫描到复查
|
|
63
|
+
|
|
64
|
+
直接说目标即可,例如:
|
|
65
|
+
|
|
66
|
+
> 体检 https://journal123.com,先别改代码。
|
|
67
|
+
|
|
68
|
+
agent 会调用 `geo_scan`,得到五维结构体检分、证据和优先级最高的修复项。工具只读扫描,不修改站点。接着:
|
|
69
|
+
|
|
70
|
+
> 生成修复清单,然后按清单改代码。
|
|
71
|
+
|
|
72
|
+
agent 调用 `geo_fix_plan` 写出 `.dsh-geo/fix-plan.md`;你或现有发布流程再改模板、响应头、robots 或 schema,最后调用一次 `geo_scan`:
|
|
73
|
+
|
|
74
|
+
- 工具输出会带 `comparison`:总分变化、已修复项、回归项、仍未通过项;
|
|
75
|
+
- `report.md` 与 `latest.json` 同步更新;
|
|
76
|
+
- 回归项会被明确列出,避免“修好一处、弄坏另一处”。
|
|
77
|
+
|
|
78
|
+
`geo_scan` 的关键参数:
|
|
79
|
+
|
|
80
|
+
- `url`(必填):入口页的绝对 http(s) URL;
|
|
81
|
+
- `max_pages`:本次抓取上限(1–50);不传用面板默认值;
|
|
82
|
+
- `now`:ISO 时间,仅用于时效检查;**复扫时复用首次的值**可以隔离“代码改动”和“时间流逝”;
|
|
83
|
+
- `allow_private`:扫描本机/私网目标,**必须先在面板开启 `permitPrivateTargets`**,否则直接拒绝;
|
|
84
|
+
- `save`:默认 `true`;设为 `false` 只返回结果、不写 `.dsh-geo/`。
|
|
85
|
+
|
|
86
|
+
## 设置面板
|
|
87
|
+
|
|
88
|
+
**设置 → GEO 体检** 读取并写入插件 Config(volatile 字段,保存立即生效,不需要重启):
|
|
89
|
+
|
|
90
|
+
| 字段 | 默认 | 说明 |
|
|
91
|
+
|---|---|---|
|
|
92
|
+
| 抓取页数上限 | 6 | 1–50,只影响扫描深度 |
|
|
93
|
+
| 遵守 robots.txt | 开 | 关闭仅适用于自有站点;每个请求、每个重定向跳转都检查 |
|
|
94
|
+
| 同主机请求间隔 | 250 ms | 0–60000;robots 的 Crawl-delay 只会调大(上限 5 秒) |
|
|
95
|
+
| 单请求超时 | 10000 ms | 单个请求的整体截止时间(含慢速正文) |
|
|
96
|
+
| 单响应体积上限 | 1.5 MB | 超出截断并标记 `truncated` |
|
|
97
|
+
| 报告目录 | `.dsh-geo` | 必须位于 `.dsh-geo/` 内,越界直接拒绝 |
|
|
98
|
+
| 允许本机/私网目标 | 关 | 双重开关:开启后工具调用仍需 `allow_private` |
|
|
99
|
+
|
|
100
|
+
## CLI
|
|
101
|
+
|
|
102
|
+
```sh
|
|
103
|
+
# 体检(不落盘)
|
|
104
|
+
dsh-geo scan https://journal123.com
|
|
105
|
+
|
|
106
|
+
# 体检并保存 + 与上次对比
|
|
107
|
+
dsh-geo scan https://journal123.com --save --now 2026-06-15T00:00:00Z
|
|
108
|
+
|
|
109
|
+
# 生成修复清单(读 .dsh-geo/latest.json)
|
|
110
|
+
dsh-geo fix-plan
|
|
111
|
+
|
|
112
|
+
# 历史与对比
|
|
113
|
+
dsh-geo history
|
|
114
|
+
dsh-geo diff .dsh-geo/history/<before>.json .dsh-geo/latest.json
|
|
115
|
+
|
|
116
|
+
# CI:低于阈值时退出码 3
|
|
117
|
+
dsh-geo scan https://journal123.com --save --fail-under 80
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
`scan --json` 输出 `{ scan, score }`(加了 `--save` 还会有 `saved` 与 `diff`),同一站点与 `--now` 下两次输出逐字节一致。
|
|
121
|
+
|
|
122
|
+
CLI 也随 npm 包提供:`npx @cobola/dsh-geo --help`;完整参数见 `dsh-geo --help`。CI 示例见 [docs/CI.md](docs/CI.md)。
|
|
123
|
+
|
|
124
|
+
退出码:`0` 完成,`1` 运行错误,`2` 用法错误,`3` 低于 `--fail-under`。
|
|
125
|
+
|
|
126
|
+
## 评分模型
|
|
127
|
+
|
|
128
|
+
| 维度 | 权重 | 回答的问题 |
|
|
129
|
+
|---|---|---|
|
|
130
|
+
| 可发现性 | 25 | 爬虫能否找到、抓取并索引页面 |
|
|
131
|
+
| 可解析性 | 20 | 不执行 JavaScript 时正文与结构是否仍可解析 |
|
|
132
|
+
| 可引用性 | 25 | 内容是否具备被 LLM 直接摘录的条件 |
|
|
133
|
+
| 实体与信任 | 15 | 站点身份是否可核实(HTTPS、组织实体、联系方式、安全头) |
|
|
134
|
+
| 机器说明书 | 15 | llms.txt、结构化数据、OpenGraph、feed、Link 提示 |
|
|
135
|
+
|
|
136
|
+
45 条可审计检查,维度内按权重归一化;`pass` 计 1、`warn` 计 0.5、`fail` 计 0、`skip` 移出分母。总分是五维加权平均。完整规则、阈值与修复建议见 **[docs/RULES.md](docs/RULES.md)**(由 `lib/rules.js` 生成)。
|
|
137
|
+
|
|
138
|
+
平台边界与官方来源见 **[docs/GOOGLE.md](docs/GOOGLE.md)** 和 **[docs/PROFILES.md](docs/PROFILES.md)**。当前默认运行 Core + Google 检查;Bing、百度、OpenAI、Perplexity 目前只是有来源的 profile 规划,不可在当前版本启用,也不把未公开的引用排序公式当成规则。
|
|
139
|
+
|
|
140
|
+
fixture 基线(参考时间 `2026-06-15T00:00:00Z`,由测试锁定):
|
|
141
|
+
|
|
142
|
+
| fixture | 总分 | 等级 | 说明 |
|
|
143
|
+
|---|---|---|---|
|
|
144
|
+
| `good-static` | 100.0 | A+ | 五维全部通过,证明满分可达 |
|
|
145
|
+
| `bad-spa` | 30.5 | F | 正文只在 JS 里,原始 HTML 仅 28 字 |
|
|
146
|
+
| `bad-robots` | 77.4 | B | 内容可读;第三方 AI 爬虫封禁会提示 warn,但 Googlebot 可抓取 |
|
|
147
|
+
|
|
148
|
+
## 安全边界
|
|
149
|
+
|
|
150
|
+
- **SSRF 防护**:只允许公网 http(s)。拒绝回环、私网、链路本地、CGNAT、NAT64/6to4/Teredo、文档网段与云元数据地址;域名先解析再校验,连接钉在校验过的 IP 上,每个重定向跳转重新校验;请求直连(`agent:false`),环境代理不能替换这条连接。
|
|
151
|
+
- **robots 默认生效**:`/llms.txt`、sitemap 与每一次重定向跳转都先检查;robots 5xx/不可访问按 RFC 9309 视为禁止抓取;空 200 视为全站允许。
|
|
152
|
+
- **重定向范围**:拒绝跨站重定向,只接受同站点的 `http → https` 或裸域 → `www`,并先加载目标源 robots。
|
|
153
|
+
- **限额**:默认 6 页、1.5 MB/响应、10 秒/请求(含整体截止)、同主机 250 ms(Crawl-delay 上限 5 秒)、HTML 解析深度 256 层。
|
|
154
|
+
- **写入范围**:只写 `<workspace>/.dsh-geo/`;`reportDir` 越界直接报错。扫描引擎本身不写文件。
|
|
155
|
+
- **私有目标双重确认**:面板开关 + 工具参数同时满足才允许回环/私网地址;云元数据地址(`169.254.169.254`、`100.100.100.200`、`fd00:ec2::254` 及其别名)即使开启私有目标也始终拒绝。
|
|
156
|
+
- **白帽建议**:修复建议只涉及服务端渲染、结构化数据、robots/sitemap、内容结构等正当手段。
|
|
157
|
+
|
|
158
|
+
## 已知边界
|
|
159
|
+
|
|
160
|
+
- **只读原始 HTML**:不执行 JavaScript,这是与检索管线对齐的设计;它不测渲染后的 DOM、Core Web Vitals、搜索排名、流量或真实 AI 引用。
|
|
161
|
+
- **不自动改代码**:`geo_fix_plan` 只产出清单;修改由 agent 或人完成,再用 `geo_scan` 验证。
|
|
162
|
+
- **评规则不是真理**:分数用于同站点纵向对比,不适合跨站点绝对排名。规则可审计、可改,带版本号 `geo-rubric@1`。
|
|
163
|
+
- **面板只编辑默认值**:历史与 diff 目前通过 `.dsh-geo/` 文件、CLI 或 agent 查看,尚未做图表 UI。
|
|
164
|
+
- **npm 上仅发布命令行与库**:作为 DSH 插件仍建议本地目录链接安装,确保读到当前 checkout。
|
|
165
|
+
|
|
166
|
+
## 开发与发布
|
|
167
|
+
|
|
168
|
+
```sh
|
|
169
|
+
npm test # 运行完整测试套件,验证规则、工具、存储、面板、CLI 与安全边界
|
|
170
|
+
npm run docs # 规则改动后重新生成 docs/RULES.md
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
npm 发布使用 GitHub Actions OIDC Trusted Publishing,不在仓库保存 npm 发布 token。首次发布前需在 npm 包设置登记 `cobola/dsh-geo` 与 `.github/workflows/publish.yml`;详见 [docs/NPM-TRUSTED-PUBLISHING.md](docs/NPM-TRUSTED-PUBLISHING.md)。
|
|
174
|
+
|
|
175
|
+
目录:
|
|
176
|
+
|
|
177
|
+
```
|
|
178
|
+
index.js 宿主半区:geo_scan / geo_fix_plan + Config
|
|
179
|
+
client.js 浏览器半区:settings.section 面板
|
|
180
|
+
lib/fetch.js SSRF 防护 + 限额 HTTP 传输
|
|
181
|
+
lib/robots.js robots.txt 解析
|
|
182
|
+
lib/html.js 无依赖 HTML 解析与事实抽取
|
|
183
|
+
lib/scan.js 抓取流程
|
|
184
|
+
lib/rules.js 45 条规则(唯一事实源)
|
|
185
|
+
lib/score.js 评分聚合(纯函数)
|
|
186
|
+
lib/report.js 报告/修复清单/diff 生成
|
|
187
|
+
lib/audit.js 工具与 CLI 共用的高层动作
|
|
188
|
+
lib/store.js .dsh-geo/ 存储与路径约束
|
|
189
|
+
bin/dsh-geo.js CLI
|
|
190
|
+
docs/RULES.md 规则手册(生成)
|
|
191
|
+
docs/GOOGLE.md Google 生成式 AI 指南对照
|
|
192
|
+
docs/PROFILES.md 平台 profile 与官方来源边界
|
|
193
|
+
docs/CI.md CI 基线与阈值
|
|
194
|
+
test/ fixture 与测试
|
|
195
|
+
```
|
package/SECURITY.md
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
## Scope
|
|
4
|
+
|
|
5
|
+
`dsh-geo` is a local-first website audit tool. It fetches public URLs, parses raw
|
|
6
|
+
HTML, and writes reports under `.dsh-geo/`. The security boundary includes:
|
|
7
|
+
|
|
8
|
+
- SSRF protection and cloud-metadata blocking;
|
|
9
|
+
- DNS validation and redirect handling;
|
|
10
|
+
- robots.txt enforcement;
|
|
11
|
+
- request, response, parser, and history limits;
|
|
12
|
+
- workspace-local report writes;
|
|
13
|
+
- DSH tool argument and cancellation handling.
|
|
14
|
+
|
|
15
|
+
## Reporting a vulnerability
|
|
16
|
+
|
|
17
|
+
Please do not open a public issue for an exploitable security problem. Until a
|
|
18
|
+
security contact is published for the project, report privately to the project
|
|
19
|
+
maintainer through the repository's private security channel, including:
|
|
20
|
+
|
|
21
|
+
1. affected version or commit;
|
|
22
|
+
2. a minimal reproduction that does not contain real credentials or private
|
|
23
|
+
customer data;
|
|
24
|
+
3. impact and prerequisites;
|
|
25
|
+
4. any proposed mitigation.
|
|
26
|
+
|
|
27
|
+
Allow reasonable time for investigation and a fix before public disclosure.
|
|
28
|
+
|
|
29
|
+
## Safe testing
|
|
30
|
+
|
|
31
|
+
- Use the included local fixtures with `allowPrivate` / `--allow-private` only
|
|
32
|
+
on systems you own.
|
|
33
|
+
- Never test cloud metadata endpoints or third-party private networks.
|
|
34
|
+
- Do not commit `.dsh-geo/latest.json` from a real site if it contains sensitive
|
|
35
|
+
page text, staging URLs, headers, or internal paths.
|
|
36
|
+
- Review reports before uploading them to CI artifacts; reports can contain
|
|
37
|
+
bounded raw-text extracts from audited pages.
|
|
38
|
+
- Do not include API keys, cookies, authorization headers, or private URLs in
|
|
39
|
+
issues, fixtures, or pull requests.
|
|
40
|
+
|
|
41
|
+
## Security design notes
|
|
42
|
+
|
|
43
|
+
The scanner is intentionally conservative: public mode rejects private and
|
|
44
|
+
reserved destinations, direct-connects instead of inheriting environment proxy
|
|
45
|
+
routing, revalidates every redirect, honors robots.txt by default, and refuses
|
|
46
|
+
to write outside the workspace's `.dsh-geo/` directory.
|