Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
github.com/jaschaephraim/lrserver
lrserver
LiveReload server for GoGolang package that implements a simple LiveReload server as described in the LiveReload protocol.
Using the recommended default port 35729:
http://localhost:35729/livereload.js
serves the LiveReload client JavaScript (https://github.com/livereload/livereload-js)
ws://localhost:35729/livereload
communicates with the client via web socket.
File watching must be implemented by your own application, and reload/alert requests sent programmatically.
Multiple servers can be instantiated, and each can support multiple connections.
go get github.com/jaschaephraim/lrserver
import "github.com/jaschaephraim/lrserver"
lr := lrserver.New(lrserver.DefaultName, lrserver.DefaultPort)
go func() {
err := lr.ListenAndServe()
if err != nil {
// Handle error
}
}()
lr.Reload("file")
lr.Alert("message")
import (
"log"
"net/http"
"github.com/fsnotify/fsnotify"
"github.com/jaschaephraim/lrserver"
)
// html includes the client JavaScript
const html = `<!doctype html>
<html>
<head>
<title>Example</title>
</head>
<body>
<script src="http://localhost:35729/livereload.js"></script>
</body>
</html>`
func Example() {
// Create file watcher
watcher, err := fsnotify.NewWatcher()
if err != nil {
log.Fatalln(err)
}
defer watcher.Close()
// Add dir to watcher
err = watcher.Add("/path/to/watched/dir")
if err != nil {
log.Fatalln(err)
}
// Create and start LiveReload server
lr := lrserver.New(lrserver.DefaultName, lrserver.DefaultPort)
go lr.ListenAndServe()
// Start goroutine that requests reload upon watcher event
go func() {
for {
select {
case event := <-watcher.Events:
lr.Reload(event.Name)
case err := <-watcher.Errors:
log.Println(err)
}
}
}()
// Start serving html
http.HandleFunc("/", func(rw http.ResponseWriter, req *http.Request) {
rw.Write([]byte(html))
})
http.ListenAndServe(":3000", nil)
}
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
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.