
Research
/Security News
Malicious npm Packages Target WhatsApp Developers with Remote Kill Switch
Two npm packages masquerading as WhatsApp developer libraries include a kill switch that deletes all files if the phone number isn’t whitelisted.
github.com/go-some/crawler
crowl 서비스의 크롤러를 구현합니다.
go get -u github.com/gocolly/colly/...
go get go.mongodb.org/mongo-driver
go get -u github.com/go-some/crawler
type Reuters struct {
}
articleCollector
의 리시버를 통해 저장합니다.News
struct 형식에 맞게 mongoDB에 저장되며 WriteDocs
(writer.go)함수에서 그 기능을 수행합니다.func (rc *Reuters) Run(wtr DocsWriter) {
// Instantiate default NewCollector
c := colly.NewCollector(
colly.MaxDepth(3),
// Visit only finance and businessnews section
colly.URLFilters(
regexp.MustCompile("https://www\\.reuters\\.com/finance"),
regexp.MustCompile("https://www\\.reuters\\.com/news/archive/businessnews.+"),
),
colly.DisallowedURLFilters(
regexp.MustCompile("https://www\\.reuters\\.com/finance/.+"),
),
)
c.AllowURLRevisit = false
// Create another collector to scrape each news article
articleCollector := colly.NewCollector()
c.OnHTML("a[href]", func(e *colly.HTMLElement) {
/* crawl all href links recursively */
link := e.Request.AbsoluteURL(e.Attr("href"))
//if the link is article page, crawl using articleCollector
//else, visit the link until MaxDepth
if strings.Index(link, "reuters.com/article") != -1 {
articleCollector.Visit(link)
} else {
e.Request.Visit(link) //e.Request.Visit을 이용해야 MaxDepth 처리가 된다.
}
})
articleCollector.OnHTML("div.StandardArticle_inner-container", func(e *colly.HTMLElement) {
/* Read article page and save to mongoDB
- 최종적으로 우리가 크롤하고자 하는 기사 페이지 (leaf node)
*/
doc := News{
Title: e.ChildText(".ArticleHeader_headline"),
Body: e.ChildText("div.StandardArticleBody_body"),
Time: e.ChildText(".ArticleHeader_date"),
Url: e.Request.URL.String(),
Origin: "Reuters",
}
cnt, err := wtr.WriteDocs([]News{doc})
if err != nil {
fmt.Println(err)
} else {
fmt.Println(cnt, "docs saved")
}
})
c.Visit("https://www.reuters.com/finance")
}
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
Two npm packages masquerading as WhatsApp developer libraries include a kill switch that deletes all files if the phone number isn’t whitelisted.
Research
/Security News
Socket uncovered 11 malicious Go packages using obfuscated loaders to fetch and execute second-stage payloads via C2 domains.
Security News
TC39 advances 11 JavaScript proposals, with two moving to Stage 4, bringing better math, binary APIs, and more features one step closer to the ECMAScript spec.