Documentation ¶
Overview ¶
sendsafely package decrypts files, combines file parts into whole files, and handles api access to the sendsafely rest api
sendsafely package decrypts files, combines file parts into whole files, and handles api access to the sendsafely rest api
sendsafely package decrypts files, combines file parts into whole files, and handles api access to the sendsafely rest api
sendsafely package decrypts files, combines file parts into whole files, and handles api access to the sendsafely rest api
sendsafely package decrypts files, combines file parts into whole files, and handles api access to the sendsafely rest api
Index ¶
- Constants
- func CombineFiles(fileNames []string, verbose bool) (totalBytesWritten int64, newFileName string, err error)
- func DecryptPart(filePart, serverSecret, keyCode string) (string, error)
- func DownloadFilesFromPackage(client Client, d downloader.GenericDownloader, a DownloadArgs) (outDir string, invalidFiles []string, err error)
- func FileSizeCheck(fileName string, fileSize int64) error
- func FindNumberedSuffix(fileName string) (bool, error)
- func Human(bytes int64) string
- func RemoveAnySuffix(fileName string) string
- func SkipFile(skipList []string, fileID string) bool
- type APIParser
- type Client
- type DownloadArgs
- type DownloadClient
- type DownloadURL
- type File
- type GopenPGP
- type InvalidSuffixErr
- type Package
- type PartRequests
- type SortingErr
Constants ¶
const DateFmt = "Jan 2, 2006 3:04:05 PM"
const URL = "https://app.sendsafely.com/api/v2.0"
Variables ¶
This section is empty.
Functions ¶
func CombineFiles ¶
func DecryptPart ¶
DecryptPart decrypts one of the file parts using the gpp protocol with the following logic from the sendsafely docs https://sendsafely.zendesk.com/hc/en-us/articles/360027599232-SendSafely-REST-API under b. Download and Decrypt File Parts
Each file part will need to be individually downloaded and decrypted using PGP. You will need to use the "Server Secret" (included in the Package Information response from Step 1) and the keycode (Client Secret) in order to compute the required decryption key.
When decrypting each file part, make sure you use the following PGP options:
* Symmetric-Key Algorithm should be 9 (AES-256) * Compression Algorithm should be 0 (Uncompressed) * Hash Algorithm should be 8 (SHA-256) * Passphrase: Server Secret concatenated with a random 256-bit Client Secret * S2k-count: 65535 * Mode: b (62)
func DownloadFilesFromPackage ¶
func DownloadFilesFromPackage( client Client, d downloader.GenericDownloader, a DownloadArgs, ) (outDir string, invalidFiles []string, err error)
func FileSizeCheck ¶ added in v0.4.7
FileSizeCheck this is to help us be aware of future patterns in the sendsafely api, often it will return a different size than it actually encountered in reality, these files are so far always usable so we are just going to log the difference
func FindNumberedSuffix ¶ added in v0.2.3
func RemoveAnySuffix ¶ added in v0.2.3
Types ¶
type APIParser ¶ added in v0.3.3
type APIParser struct {
// contains filtered or unexported fields
}
APIParser stores the jsonParser so it can be shared between operations, this mainly benefits the parsing of the file parts
func (*APIParser) ParseDownloadUrls ¶ added in v0.3.3
func (s *APIParser) ParseDownloadUrls(downloadJSON string) ([]DownloadURL, error)
ParseDownloadUrls reads the json response provided here https://bump.sh/doc/sendsafely-rest-api#operation-post-package-parameter-file-parameter-download-urls here is an example
{ "downloadUrls": [ { "part": 1, "url": "https://sendsafely-dual-region-us.s3-accelerate.amazonaws.com/commercial/AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE/11111111-2222-3333-4444-555555555555-1?AWSAccessKeyId=AKIAIOSFODNN7EXAMPLE&Expires=1554862678&Signature=OTP5Z0DIutXKbRRT4NwmxQG9jFk%3D" } ], "response": "SUCCESS" }
func (*APIParser) ParsePackage ¶ added in v0.3.3
ParsePackage reads a json from here https://bump.sh/doc/sendsafely-rest-api#operation-getpackageinformation which looks like the following
{ "packageId": "GVG2-MNZT", "packageCode": "M0AEMIrTQe9XWRgGDKiKta1pXobmpKwAVafWgXjnBsw", "serverSecret": "ACbuj9NKTkvjZ71Gc0t5zuU1xvba9XAouA", "recipients": [ { "recipientId": "5d504769-78c4-4c0a-b982-945845ea2075", "email": "recip1@example.com", "fullName": "External User", "needsApproval": false, "recipientCode": "YN0P1G0xbS9mBSwohP9xPJSqwgKXMq4bCI5uTcx1KKM", "confirmations": { "ipAddress": "127.0.0.1", "timestamp": "Dec 12, 2018 2:24:38 PM", "timeStampStr": "Dec 12, 2018 at 14:24", "isMessage": true }, "isPackageOwner": false, "checkForPublicKeys": false, "roleName": "VIEWER" } ], "contactGroups": [ { "id": "string" } ], "files": [ { //NOTE THIS IS NOTHING LIKE WHAT IT RETURNS see SendSafelyFile for the accurate field names and types "id": "string" } ], "directories": [ { "id": "string" } ], "approverList": [ {} ], "needsApproval": false, "state": "PACKAGE_STATE_IN_PROGRESS", "passwordRequired": false, "life": 10, "isVDR": false, "isArchived": false, "packageSender": "user@companyabc.com", "packageTimestamp": "Feb 1, 2019 2:07:28 PM", "rootDirectoryId": "8c3c2184-e73e-4137-be92-e9c5b5661258", "response": "SUCCESS" }
type Client ¶ added in v0.3.3
type DownloadArgs ¶ added in v0.4.9
type DownloadClient ¶ added in v0.4.9
type DownloadClient struct {
// contains filtered or unexported fields
}
Client uses the SendSafely REST Api to enable automation of SendSafely in Go
func (*DownloadClient) GetDownloadUrlsForFile ¶ added in v0.4.9
func (s *DownloadClient) GetDownloadUrlsForFile(p Package, fileID, keyCode string, start, end int) ([]DownloadURL, error)
Payload ¶
{ "checksum": "20ea6189a58d6618164d6b53cbc7b5dbeef2fa9a61186b13a80cf1f620987bc1", "startSegment": 1, "endSegment": 25 }
func (*DownloadClient) RetrievePackageByID ¶ added in v0.4.9
func (s *DownloadClient) RetrievePackageByID(packageID string) (Package, error)
type DownloadURL ¶ added in v0.3.3
DownloadURL provides the part id and the actual url to get the file the Part field tells you the order of the parts so you can reconstruct the file after downloading it https://bump.sh/doc/sendsafely-rest-api#operation-post-package-parameter-file-parameter-download-urls
type File ¶ added in v0.3.3
type File struct { FileID string FileName string FileSize int64 Parts int FileUploaded time.Time FileUploadedStr string FileVersion string CreatedByEmail string }
File are curious as near as they do not match the SendSafely documentation for what a package returns This was discovered by returning the values
type GopenPGP ¶
type GopenPGP struct {
// contains filtered or unexported fields
}
GopenPGP is used as a "namespace" for many of the functions in this package. It is a struct that keeps track of time skew between server and client.
type InvalidSuffixErr ¶ added in v0.3.0
type InvalidSuffixErr struct {
FileName string
}
func (InvalidSuffixErr) Error ¶ added in v0.3.0
func (i InvalidSuffixErr) Error() string
type Package ¶ added in v0.3.3
type Package struct { PackageID string PackageCode string Files []File DirectoryIds []string State string PackageTimestamp time.Time Response string ServerSecret string }
Package is the struct we need that maps to the fields here: https://bump.sh/doc/sendsafely-rest-api#operation-getpackageinformation this is intentionally not complete as we do nto need all the fields
type PartRequests ¶
type SortingErr ¶ added in v0.3.0
type SortingErr struct {
BaseErr error
}
func (SortingErr) Error ¶ added in v0.3.0
func (s SortingErr) Error() string