ogórek

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 1, 2018 License: MIT Imports: 11 Imported by: 0

README

ogórek

GoDoc Build Status

ogórek is a Go library for encoding and decoding pickles.

Fuzz Testing

Fuzz testing has been implemented for the decoder. To run fuzz tests do the following:

go get github.com/dvyukov/go-fuzz/go-fuzz
go get github.com/dvyukov/go-fuzz/go-fuzz-build
go-fuzz-build github.com/kisielk/og-rek
go-fuzz -bin=./ogórek-fuzz.zip -workdir=./fuzz

Documentation

Overview

Package ogórek is a library for decoding Python's pickle format.

ogórek is Polish for "pickle".

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidPickleVersion = errors.New("invalid pickle version")

Functions

This section is empty.

Types

type Call

type Call struct {
	Callable Class
	Args     Tuple
}

Call represents Python's call.

type Class

type Class struct {
	Module, Name string
}

Class represents a Python class.

type Decoder

type Decoder struct {
	// contains filtered or unexported fields
}

Decoder is a decoder for pickle streams.

func NewDecoder

func NewDecoder(r io.Reader) *Decoder

NewDecoder constructs a new Decoder which will decode the pickle stream in r.

func (*Decoder) Decode

func (d *Decoder) Decode() (interface{}, error)

Decode decodes the pickle stream and returns the result or an error.

type Encoder

type Encoder struct {
	// contains filtered or unexported fields
}

An Encoder encodes Go data structures into pickle byte stream

func NewEncoder

func NewEncoder(w io.Writer) *Encoder

NewEncoder returns a new Encoder struct with default values

func (*Encoder) Encode

func (e *Encoder) Encode(v interface{}) error

Encode writes the pickle encoding of v to w, the encoder's writer

type None

type None struct{}

None is a representation of Python's None.

type OpcodeError

type OpcodeError struct {
	Key byte
	Pos int
}

OpcodeError is the error that Decode returns when it sees unknown pickle opcode.

func (OpcodeError) Error

func (e OpcodeError) Error() string

type Ref

type Ref struct {
	// persistent ID of referenced object.
	//
	// used to be string for protocol 0, but "upgraded" to be arbitrary
	// object for later protocols.
	Pid interface{}
}

Ref represents Python's persistent reference.

Such references are used when one pickle somehow references another pickle in e.g. a database.

See https://docs.python.org/3/library/pickle.html#pickle-persistent for details.

type Tuple

type Tuple []interface{}

Tuple is a representation of Python's tuple.

type TypeError

type TypeError struct {
	// contains filtered or unexported fields
}

func (*TypeError) Error

func (te *TypeError) Error() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL