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/tunabay/go-infounit
go-infounit is a Go package providing three data types for units of information:
ByteCount
- number of bytes with both SI and binary prefixesBitCount
- number of bits with both SI and binary prefixesBitRate
- number of bits transferred or processed per unit of timeThese values can be converted to human-readable string representations
using the standard fmt.Printf
family functions:
import (
"fmt"
"github.com/tunabay/go-infounit"
)
func main() {
size := infounit.Megabyte * 2500
fmt.Printf("% s\n", size) // "2.5 GB"
fmt.Printf("% .1S\n", size) // "2.3 GiB"
fmt.Printf("%# .2s\n", size) // "2.50 gigabytes"
fmt.Printf("%# .3S\n", size) // "2.328 gibibytes"
fmt.Printf("%d\n", size) // "2500000000"
bits := infounit.Kilobit * 32
fmt.Printf("% s\n", bits) // "32 kbit"
fmt.Printf("% S\n", bits) // "31.25 Kibit"
fmt.Printf("%# .2s\n", bits) // "32.00 kilobits"
fmt.Printf("%# .3S\n", bits) // "31.250 kibibits"
fmt.Printf("%d\n", bits) // "32000"
rate := infounit.GigabitPerSecond * 123.45
fmt.Printf("% s\n", rate) // "123.45 Gbit/s"
fmt.Printf("% .3S\n", rate) // "114.972 Gibit/s"
fmt.Printf("%# .1s\n", rate) // "123.5 gigabits per second"
fmt.Printf("%# .2S\n", rate) // "114.97 gibibits per second"
fmt.Printf("% .1a\n", rate) // "123.5 Gbps"
fmt.Printf("% .2A\n", rate) // "114.97 Gibps"
}
%s
is for SI prefixes and %S
is for binary prefixes.%a
and %A
for BitRate
use the non-standard abbreviation "bps".' '
(space) flag puts a space between digits and the unit suffix.'#'
flag uses long unit suffixes.They also implement convenience methods for:
go-infounit is available under the MIT license. See the LICENSE file for more information.
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.