ax

package module
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2021 License: MIT Imports: 10 Imported by: 0

README ¶

AX

Automatically create password-protected archives with an additional layer of AES Encryption on top of it! 🔒

GolangCI Build release Version Coverage Status

NOTE: This is a Work In Progress
Check out the GH Project Dashboard for more info on all the tasks that have to be completed before AX will reach a stable version.

AX provides the ability to easily create password-protected archives from chosen directory, and apply an additional layer of AES encryption once first iteration has been completed. Passwords which are used for Archive protection and AES encryption can (and SHOULD) be different. Recommended length is > 14 for better entropy, and as complex as you can get it.


Table of Contents

Getting Started

Currently, in active development - should become stable by second week of April '21. Do not use until version badge becomes 💚 until adequate testing coverage has been applied.

Feel free to download preferred version from the releases page. Most operating systems & architectures are supported.

If you wish to use it as a module for your own product, you can

$ go get -u github.com/kaynetik/ax

If you want to use it as an CLI, you can download & run ax in the following way:

$ curl -s https://api.github.com/repos/kaynetik/ax/releases/latest | grep "browser_download_url.*linux_x86_64.*\"" | cut -d : -f 2,3 | tr -d \" | wget -qi - 
$ tax -xvzf ax_linux_x86_64.tar.gz
$ ./ax -help
$ ./ax # To enter interactive mode don't provide any flags
$ ./ax -arc-in ../tmp_to_archive -arc-pass on -arc-out ../tmp_archive_out # Example usage with flags

Example above was to download latest release for linux x86_64 architecture. Same oneliner will work for any OS, you just need to alter grep counterpart, i.e. instead of linux_x86_64 place windows_x86_64.

Refer to makefile for examples of CLI usage. Proper examples will be provided before first stable release.

This is still WIP

Current focus are the following:

Precise info on priorities can be reached on the GH Issues Page.

  1. Add more flexibility to the PushToGIT functionality
  2. Add support to PullFromGIT & automatically decrypt and extract, given proper credentials were given
  3. Add automated release build and generate portable executables + Fix issue with the build for win executable - can't use term.ReadPassword -> issue was that Win doesn't support syscall, fixed now.
  4. Cover with unit-tests
  5. Start the GUI wrapper [will be in a separate repo]

Documentation ¶

Index ¶

Constants ¶

View Source
const (

	// BlockSizeByte - Byte representative character.
	BlockSizeByte = BlockSize(letterB)

	// BlockSizeKB - KB representative character.
	BlockSizeKB = BlockSize(letterK)

	// BlockSizeMB - MB representative character.
	BlockSizeMB = BlockSize(letterM)

	// BlockSizeGB - GB representative character.
	BlockSizeGB = BlockSize(letterG)
)

Variables ¶

View Source
var (
	// ErrNotDir - path is not a directory.
	// Currently only archiving dirs has been thoroughly tested.
	ErrNotDir = errors.New("path is not a directory")

	// ErrPathEmpty - path can not be empty.
	ErrPathEmpty = errors.New("path can not be empty")
)
View Source
var ErrCmdWrapFn = func(cmd, cmdArgs string, err error) error {
	cmdSlc := strings.Fields(cmdArgs)

	return fmt.Errorf("%s: failed executing the command with args[%v]: %w", cmd, cmdSlc, err)
}

ErrCmdWrapFn - func used to wrap errors caused by executeCommand, if any.

Functions ¶

func Archive ¶

func Archive(conf *ArchiveConfig) error

Archive - used to create archive zip volume(s) from a chosen directory.

func DefaultFileDecryption ¶ added in v0.0.4

func DefaultFileDecryption(passwd []byte, fileList []string) error

DefaultFileDecryption -- represents basic usage of the FileDecryption func.

func DefaultFileEncryption ¶ added in v0.0.4

func DefaultFileEncryption(passwd []byte, fileList []string) error

DefaultFileEncryption - represents basic usage of the FileEncryption func.

func DefaultPathWalkerFunc ¶ added in v0.0.12

func DefaultPathWalkerFunc(fileList *[]string) filepath.WalkFunc

DefaultPathWalkerFunc - returns default implementation of filepath.WalkFunc.

This approach enables the flexibility to override the filepath.WalkFunc used by our ListFiles func.

func Extract ¶ added in v0.0.2

func Extract(conf *ExtractConfig) error

Extract - used to extract the archive(s).

func FileDecryption ¶ added in v0.0.4

func FileDecryption(key []byte, encFileName, decFileName string)

FileDecryption - decrypt a file.

func FileEncryption ¶ added in v0.0.4

func FileEncryption(bytKey []byte, inFileName, encFileName string)

FileEncryption - encrypt a file.

func ListFiles ¶

func ListFiles(pathToWalk string, walkFuncBuilder walkFuncBuilder) ([]string, error)

ListFiles - used to list files, without directories in a chosen path.

func PushToGIT ¶

func PushToGIT(gitRepo string, args ...gitChain) error

PushToGIT - used to commit&push created archive(s) to the remote GIT Repository.

func RunTestCases ¶ added in v0.0.12

func RunTestCases(s SuiteRunner, testCases []TestCase)

RunTestCases - func executing the passed testing Suite.

Types ¶

type ArchiveConfig ¶ added in v0.0.3

type ArchiveConfig struct {
	// PathConfig - embeds required path information for archiving process.
	PathConfig

	// Password - if set, it will be used to encrypt the archive.
	Password []byte

	// ArchiveType - default setting '-t7z'.
	ArchiveType string

	// BlockSize - default setting 'm' [BlockSizeMB].
	BlockSize BlockSize // b,k,m,g - size representation

	// VolumeSize - default setting '-v9m' - representing volumes of 9Megabytes each.
	VolumeSize uint64

	// FastBytes - default setting '-mfb=64', where the number set represents the number of Fast bytes for LZMA.
	FastBytes uint16

	// DictSize - default setting '-md=64m.
	DictSize uint16

	// ApplyPassword - if true, then password flag for 7zip cmd will be used.
	ApplyPassword bool

	// HeadersEncryption - default setting '-mhe=on'. Enables Headers encryption.
	HeadersEncryption bool // -he=on

	// Compression - default setting '-mx=9', where 9 represents Ultra and 0 would be none compression at all.
	Compression uint8

	// SolidArchive - default setting '-ms=on'
	SolidArchive bool
}

ArchiveConfig - represents the config required for the archiving process.

If it's not provided, then default one will be used. Note that default setting is 'Ultra' (highest compression). This config will be just append-only, to keep API consistency. Preferred over params in order to avoid breaking API with future updates.

func NewDefaultArchiveConfig ¶ added in v0.0.3

func NewDefaultArchiveConfig() ArchiveConfig

NewDefaultArchiveConfig - returns ArchiveConfig with default values pre-set.

Note that default setting is 'Ultra' (highest compression).

type BlockSize ¶

type BlockSize string

BlockSize - represents size of the volume blocks in b|k|m|g.

func DetermineBlockSize ¶

func DetermineBlockSize(bs string) BlockSize

DetermineBlockSize - returns BlockSize casted from an input string.

func (*BlockSize) String ¶

func (v *BlockSize) String() string

type ExtractConfig ¶ added in v0.0.2

type ExtractConfig struct {
	// Password - if set, it will be used to decrypt the archive.
	Password []byte

	// ExtractPath - path which points to the directory to archive(s) location (for extraction).
	ExtractPath string
}

ExtractConfig - represents configuration which is required for 7zip extraction process.

type PathConfig ¶ added in v0.0.3

type PathConfig struct {
	// PathToArchive - path which points to the directory which should be archived.
	// Should be relative to the current working dir.
	PathToArchive string

	// OutputPath - path where the temporary archive files should be placed.
	OutputPath string

	// NewArchiveName - if set it will represent the base for the name of output archive(s).
	NewArchiveName string
}

PathConfig - path config required for the archiving process.

type SuiteRunner ¶ added in v0.0.12

type SuiteRunner interface {
	Run(name string, subtest func()) bool
}

SuiteRunner - interface for running testing Suite.

type TestCase ¶ added in v0.0.12

type TestCase struct {
	Name          string
	PreRequisites func()
	Assert        func()

	SubTests []TestCase
}

TestCase - base case struct used in testing Suite.

Directories ¶

Path Synopsis
cmd
cli command
pkg

Jump to

Keyboard shortcuts

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