
Research
Security News
The Landscape of Malicious Open Source Packages: 2025 Mid‑Year Threat Report
A look at the top trends in how threat actors are weaponizing open source packages to deliver malware and persist across the software supply chain.
github.com/Diwamoto/alb-log-parser
A Go library for parsing AWS Application Load Balancer (ALB) access logs. This library provides a simple and efficient way to parse ALB log entries into structured data.
go get github.com/Diwamoto/alb-log-parser
Here's a simple example of how to use the library:
package main
import (
"fmt"
"compress/gzip"
"os"
"bufio"
albparser "github.com/Diwamoto/alb-log-parser"
)
func main() {
// Create a new parser instance
parser := albparser.NewAlbLogParser()
// Open gzipped ALB log file
// ALB logs are often in gz format when fetched from S3.
f, err := os.Open("alb-logs.gz")
if err != nil {
fmt.Printf("Error opening file: %v\n", err)
return
}
defer f.Close()
// Create gzip reader
gz, err := gzip.NewReader(f)
if err != nil {
fmt.Printf("Error creating gzip reader: %v\n", err)
return
}
defer gz.Close()
// Read line by line
scanner := bufio.NewScanner(gz)
for scanner.Scan() {
record, err := parser.ParseAlbLog(scanner.Text())
if err != nil {
fmt.Printf("Error parsing log: %v\n", err)
continue
}
// Access the parsed fields
fmt.Printf("Request Method: %s\n", record.HttpMethod)
fmt.Printf("Status Code: %s\n", record.ElbStatusCode)
fmt.Printf("Client IP: %s\n", record.ClientIP)
}
if err := scanner.Err(); err != nil {
fmt.Printf("Error reading file: %v\n", err)
}
}
others
package main
import (
"fmt"
albparser "github.com/Diwamoto/alb-log-parser"
)
func main() {
// Create a new parser instance
parser := albparser.NewAlbLogParser()
// Example ALB log line
logLine := `http 2024-01-01T12:00:00.000000Z app/my-loadbalancer/1234567890 172.16.1.1:1234 10.0.1.1:80 0.001 0.002 0.003 200 200 123 456 "GET https://example.com/ HTTP/1.1" ...`
// Parse the log line
record, err := parser.ParseAlbLog(logLine)
if err != nil {
fmt.Printf("Error parsing log: %v\n", err)
return
}
// Access the parsed fields
fmt.Printf("Request Method: %s\n", record.HttpMethod)
fmt.Printf("Status Code: %s\n", record.ElbStatusCode)
fmt.Printf("Client IP: %s\n", record.ClientIP)
}
The parser extracts all fields from ALB access logs.
For a complete list of supported fields, see the AWS documentation.
Contributions are welcome! Please feel free to submit pull requests. For major changes, please open an issue first to discuss what you would like to change.
git checkout -b feature/amazing-feature
)git commit -m 'Add some amazing feature'
)git push origin feature/amazing-feature
)This project is licensed under the MIT License - see the LICENSE file for details.
Diwamoto (@Diwamoto)
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
A look at the top trends in how threat actors are weaponizing open source packages to deliver malware and persist across the software supply chain.
Security News
ESLint now supports HTML linting with 48 new rules, expanding its language plugin system to cover more of the modern web development stack.
Security News
CISA is discontinuing official RSS support for KEV and cybersecurity alerts, shifting updates to email and social media, disrupting automation workflows.