New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

github.com/golangorg/formstash

Package Overview
Dependencies
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
This package has malicious versions linked to the ongoing "North Korea’s Contagious Interview Campaign" supply chain attack.

Affected versions:

v1.0.3v1.0.4
View campaign page

github.com/golangorg/formstash

Source
Go Modules
Version
v1.0.5
Version published
Created
Source
                         
 ▄▄▄▄    ▄▄▄       ██▀███   ▄▄▄       ██ ▄█▀▄▄▄      
▓█████▄ ▒████▄    ▓██ ▒ ██▒▒████▄     ██▄█▒▒████▄    
▒██▒ ▄██▒██  ▀█▄  ▓██ ░▄█ ▒▒██  ▀█▄  ▓███▄░▒██  ▀█▄  
▒██░█▀  ░██▄▄▄▄██ ▒██▀▀█▄  ░██▄▄▄▄██ ▓██ █▄░██▄▄▄▄██ 
░▓█  ▀█▓ ▓█   ▓██▒░██▓ ▒██▒ ▓█   ▓██▒▒██▒ █▄▓█   ▓██▒
░▒▓███▀▒ ▒▒   ▓▒█░░ ▒▓ ░▒▓░ ▒▒   ▓▒█░▒ ▒▒ ▓▒▒▒   ▓▒█░
▒░▒   ░   ▒   ▒▒ ░  ░▒ ░ ▒░  ▒   ▒▒ ░░ ░▒ ▒░ ▒   ▒▒ ░
 ░    ░   ░   ▒     ░░   ░   ░   ▒   ░ ░░ ░  ░   ▒   
 ░            ░  ░   ░           ░  ░░  ░        ░  ░
      ░                                              
	

Go Report Card codecov Build Status go.dev reference

a tool for handling file uploads for http servers

makes it easier to make operations with files from the http request.

Contents

Install

go get github.com/golangorg/formstash/v2

Simple Usage

func main() {
	// create a parser
	parser := formstash.NewParser(formstash.ParserOptions{
		MaxFileSize:   5 << 20,
		MaxFileCount:  5,
		MaxParseCount: 5,
	})

	store := formstash.NewFilesystemStorage("./files")

	router := gin.Default()
	router.POST("/upload", func(c *gin.Context) {
		// parse
		request, err := parser.Parse(c.Request)
		if err != nil {
			fmt.Println(err)
		}

		// get the form
		images, err := request.GetForm("images")
		if err != nil {
			fmt.Println(err)
		}

		// save
		for key, image := range images {
			err = store.Save("images", "image_"+strconv.Itoa(key), image)
			if err != nil {
				fmt.Println(err)
			}
		}
	})
	router.Run()
}

You can use formstash with the other http server libraries, just pass the http.Request to the parser.Parse function.

Filtering Parts

You can filter parts by their properties, like part's content type. Parser can inspect the part's bytes and detect the type of the part with the Inspector.

// create a parser
parser := formstash.NewParser(formstash.ParserOptions{
	MaxFileSize:   5 << 20,
	MaxFileCount:  5,
	MaxParseCount: 5,
})

// give parser an inspector
parser.SetInspector(formstash.NewDefaultInspector(512))
// give parser a filter
parser.SetFilter(formstash.NewExtensionFilter(".jpg"))

Now parser will inspect the each part and it will just return the jpeg ones from the Parse function. You can make your own Inspector and Filter.

Contribute

Pull requests are welcome. please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

FAQs

Package last updated on 03 Apr 2026

Did you know?

Socket

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.

Install

Related posts