Một mục tập trung giao diện trong kho dữ liệu GitHub của TopGit: BishopFox/jsluice, 2.0k sao, nhóm Frontend, Go. Extract URLs, paths, secrets, and other interesting bits from JavaScript
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
jsluice is a Go package and command-line tool for extracting URLs, paths, secrets,
and other interesting data from JavaScript source code.
If you want to do those things right away: look at the command-line tool.
If you want to integrate jsluice's capabilities with your own project: look at the examples,
and read the package documentation.
Install
To install the command-line tool, run:
▶ go install github.com/BishopFox/jsluice/cmd/jsluice@latest
To add the package to your project, run:
▶ go get github.com/BishopFox/jsluice
Extracting URLs
Rather than using regular expressions alone, jsluice uses go-tree-sitter to look for places that URLs are known to be used,
such as being assigned to document.location, passed to window.open(), or passed to fetch() etc.
jsluice understands string concatenation, and replaces any expressions it cannot know the value
of with EXPR. Although not a foolproof solution, this approach results in a valid URL or path
more often than not, and means that it's possible to discover things that aren't easily found using
other approaches. In this case, a naive regular expression may well miss the method query string
parameter:
jsluice comes with some built-in URL matchers for common scenarios, but you can add more
with the AddURLMatcher function:
analyzer := jsluice.NewAnalyzer([]byte(`
var fn = () => {
var meta = {
contact: "mailto:[email protected]",
home: "https://example.com"
}
return meta
}
`))
analyzer.AddURLMatcher(
// The first value in the jsluice.URLMatcher struct is the type of node to look for.
// It can be one of "string", "assignment_expression", or "call_expression"
jsluice.URLMatcher{"string", func(n *jsluice.Node) *jsluice.URL {
val := n.DecodedString()
if !strings.HasPrefix(val, "mailto:") {
return nil
}
return &jsluice.URL{
URL: val,
Type: "mailto",
}
}},
)
for _, match := range analyzer.GetURLs() {
fmt.Println(match.URL)
}
There's a copy of this example here. You can run it like this:
▶ go run examples/urlmatcher/main.go
mailto:[email protected]
https://example.com
jsluice doesn't match mailto: URIs by default, it was found by the custom URLMatcher.
Extracting Secrets
As well as URLs, jsluice can extract secrets. As with URL extraction, custom matchers can
be supplied to supplement the default matchers. There's a short example program here
that does just that:
analyzer := jsluice.NewAnalyzer([]byte(`
var config = {
apiKey: "AUTH_1a2b3c4d5e6f",
apiURL: "https://api.example.com/v2/"
}
`))
analyzer.AddSecretMatcher(
// The first value in the jsluice.SecretMatcher struct is a
// tree-sitter query to run on the JavaScript source.
jsluice.SecretMatcher{"(pair) @match", func(n *jsluice.Node) *jsluice.Secret {
key := n.ChildByFieldName("key").DecodedString()
value := n.ChildByFieldName("value").DecodedString()
if !strings.Contains(key, "api") {
return nil
}
if !strings.HasPrefix(value, "AUTH_") {
return nil
}
return &jsluice.Secret{
Kind: "fakeApi",
Data: map[string]string{
"key": key,
"value": value,
},
Severity: jsluice.SeverityLow,
Context: n.Parent().AsMap(),
}
}},
)
for _, match := range analyzer.GetSecrets() {
j, err := json.MarshalIndent(match, "", " ")
if err != nil {
continue
}
fmt.Printf("%s\n", j)
}
Because we have a syntax tree available for the entire JavaScript source,
it was possible to inspect both the key and value, and also to easily
provide the parent object as context for the match.
BishopFox/jsluice có 2.0k sao GitHub — tải lại trang để xem số mới nhất, hoặc xem trực tiếp github.com/BishopFox/jsluice. TopGit phản chiếu số sao của GitHub nhưng không cam kết đến từng phút.
BishopFox/jsluice có phải mã nguồn mở không?
Có — BishopFox/jsluice phát hành theo license MIT, nghĩa là mã nguồn mở để đọc, fork và (tùy license) tái sử dụng. Mã: github.com/BishopFox/jsluice.
BishopFox/jsluice còn đang phát triển không?
Commit gần nhất trên BishopFox/jsluice là 2.5 năm trước (theo timestamp GitHub). Repo có 152 fork — một chỉ báo về mức độ quan tâm của cộng đồng.
BishopFox/jsluice là gì?
BishopFox/jsluice (BishopFox/jsluice) là dự án Go trên GitHub. Theo mô tả gốc: Extract URLs, paths, secrets, and other interesting bits from JavaScript
BishopFox/jsluice so với các dự án Frontend khác thế nào?
BishopFox/jsluice được TopGit xếp vào nhóm Frontend, với 2.0k sao GitHub và viết bằng Go. Xem trang chủ đề Frontend trên TopGit để so sánh với các dự án tương tự theo số sao và mức độ hoạt động.
Đọc thêm về BishopFox/jsluice ở đâu?
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/BishopFox/jsluice là nguồn chính thức.
Đọc đầy đủ README ở tab phía trên.
Vẫn đang phân vân về jsluice?
Một cú bấm sẽ gửi câu hỏi kèm trang này cho AI — xem AI nói gì về jsluice.