Browse Source

Work with new file format + drone

tags/v0.1
Sarah Jamie Lewis 2 months ago
parent
commit
22280af95b
2 changed files with 175 additions and 12 deletions
  1. +153
    -0
      .drone.yml
  2. +22
    -12
      api/api.go

+ 153
- 0
.drone.yml View File

@@ -0,0 +1,153 @@
workspace:
base: /media/sf_GOPATH1/src/git.openprivacy.ca/lockbox
path: ui

pipeline:
build-linux:
mem_limit: 3G
image: therecipe/qt:linux_static
when:
repo: git.openprivacy.ca/lockbox
branch: master
event: [ push, pull_request ]
environment:
- QT_DIR=/opt/Qt
- QT_DOCKER='true'
- QT_API=5.13.0
- GO111MODULE=on
commands:
- export PATH=$PATH:/home/user/work/bin:/media/sf_GOPATH1/bin
- apt-get -qq update && apt-get --no-install-recommends -qq -y install ca-certificates curl git openssh-client
- go mod download
- $QT_DIR/$QT_API/gcc_64/bin/lrelease ui.pro
- git fetch --tags
- export VERSION=`git describe --tags`
- export BUILDDATE=`date +%G-%m-%d-%H-%M`
- go mod vendor
- qtdeploy -ldflags "-X main.buildVer=$VERSION -X main.buildDate=$BUILDDATE" build linux
- cp README.md deploy/linux
- cp -R assets deploy/linux/
- export FILENAME=lockbox-linux-$BUILDDATE.tar.gz
- cd deploy
- mv linux lockbox
- tar -czf $FILENAME lockbox
- sha256sum $FILENAME > $FILENAME.sha256
- rm -r lockbox
build-android:
mem_limit: 3G
image: therecipe/qt:android
when:
repo: git.openprivacy.ca/lockbox
branch: master
event: push
environment:
- QT_DIR=/opt/Qt
- QT_DOCKER='true'
- QT_API=5.13.0
- ANDROID_NDK_DIR=/home/user/android-ndk-r18b
- ANDROID_SDK_DIR=/home/user/android-sdk-linux
- GO111MODULE=on
commands:
- export PATH=$PATH:/home/user/work/bin:/media/sf_GOPATH1/bin
- apt-get -qq update && apt-get --no-install-recommends -qq -y install ca-certificates curl git
- rm -r vendor/
- make clean
- go mod download
- export VERSION=`git describe --tags`
- export BUILDDATE=`date +%G-%m-%d-%H-%M`
- go mod vendor
- qtsetup generate android
- mv assets android/
- qtdeploy -ldflags "-X main.buildVer=$VERSION -X main.buildDate=$BUILDDATE" build android
- mv android/assets assets
- cd deploy
- export FILENAME=lockbox-android-$BUILDDATE.apk
- cp android/build-debug.apk $FILENAME
- sha256sum $FILENAME > $FILENAME.sha256
build-windows:
mem_limit: 3G
image: therecipe/qt:windows_64_static
when:
repo: git.openprivacy.ca/lockbox
branch: [ master, windows_build ]
event: push
environment:
- QT_DIR=/opt/Qt
- QT_DOCKER='true'
- QT_API=5.13.0
- GO111MODULE=on
commands:
- export PATH=$PATH:/home/user/work/bin:/media/sf_GOPATH1/bin
- apt-get -qq update && apt-get --no-install-recommends -qq -y install ca-certificates curl git zip
- rm -r vendor || true
- make clean || true
- go mod download
- export VERSION=`git describe --tags`
- export BUILDDATE=`date +%G-%m-%d-%H-%M`
- go mod vendor
- qtdeploy -ldflags "-X main.buildVer=$VERSION -X main.buildDate=$BUILDDATE" build windows
- cp README.md deploy/windows
- cp -R assets deploy/windows/
- cp -r windows/* deploy/windows
- cd deploy
- mv windows lockbox
- export FILENAME=lockbox-windows-$BUILDDATE.zip
- zip -r $FILENAME lockbox
- sha256sum $FILENAME > $FILENAME.sha256
- rm -r lockbox
deploy-buildfiles:
image: pivotaldata/concourse-ssh
secrets: [buildfiles_key]
when:
repo: git.openprivacy.ca/lockbox
branch: master
event: push
status: [ success ]
commands:
- apk add --no-cache git
- echo $BUILDFILES_KEY > ~/id_rsab64
- base64 -d ~/id_rsab64 > ~/id_rsa
- chmod 400 ~/id_rsa
- export DIR=`date +%G.%m.%d-%H.%M`-`git describe --tags`
- cd deploy
- mkdir $DIR
- mv lockbox* $DIR/
- scp -r -o StrictHostKeyChecking=no -i ~/id_rsa $DIR buildfiles@openprivacy.ca:/home/buildfiles/buildfiles/
deploy-windows-build:
image: pivotaldata/concourse-ssh
secrets: [buildfiles_key]
when:
repo: git.openprivacy.ca/lockbox
branch: windows_build
event: push
status: [ success ]
commands:
- apk add --no-cache git
- echo $BUILDFILES_KEY > ~/id_rsab64
- base64 -d ~/id_rsab64 > ~/id_rsa
- chmod 400 ~/id_rsa
- git fetch --tags
- export DIR=`date +%G.%m.%d-%H.%M`-`git describe --tags`
- cd deploy
- mkdir -p windows_build/$DIR
- mv lockbox* windows_build/$DIR/
- scp -r -o StrictHostKeyChecking=no -i ~/id_rsa windows_build buildfiles@openprivacy.ca:/home/buildfiles/buildfiles/
notify-email:
image: drillster/drone-email
host: build.openprivacy.ca
port: 25
skip_verify: true
from: drone@openprivacy.ca
when:
repo: git.openprivacy.ca/lockbox
branch: master
status: [ failure ]
notify-gogs:
image: openpriv/drone-gogs
when:
repo: git.openprivacy.ca/lockbox
branch: master
event: pull_request
status: [ success, changed, failure ]
secrets: [gogs_account_token]
gogs_url: https://git.openprivacy.ca

+ 22
- 12
api/api.go View File

@@ -46,6 +46,7 @@ func (lapi *LockBoxAPI) decryptFile(inputFilename string, outputFilename string,

file, err := os.Open(cleanPath(inputFilename))
outputfile := []string{}
count := 1
if err == nil {
defer file.Close()

@@ -64,7 +65,7 @@ func (lapi *LockBoxAPI) decryptFile(inputFilename string, outputFilename string,
data := make(map[string]string)
err := json.Unmarshal(message, &data)
if err == nil {
outputLine := ""
outputLine := "num,"
if schemeDefined == false {
for k := range data {
schema = append(schema, k)
@@ -86,11 +87,12 @@ func (lapi *LockBoxAPI) decryptFile(inputFilename string, outputFilename string,
outputfile = append(outputfile, outputLine)
schemeDefined = true
}
outputLine = ""
outputLine = fmt.Sprintf("%d,", count)
for _, k := range schema {
outputLine += fmt.Sprintf(`"%v",`, strings.ReplaceAll(data[k], "\"", "\\\""))
}
outputfile = append(outputfile, outputLine)
count++
}
} else {
lapi.Decrypted(false, "Error Decrypting File: You might be using the wrong decryption key with this file")
@@ -114,23 +116,31 @@ func (lapi *LockBoxAPI) decryptFile(inputFilename string, outputFilename string,

func (lapi *LockBoxAPI) generateKey(keyPath string) {
log.Infof("Saving Key to Path to %v", keyPath)
public, private, err := box.GenerateKey(rand.Reader)

_,err := os.Stat(cleanPath(path.Join(cleanPath(keyPath), "key.private")))
if err == nil {
publicStr := base64.StdEncoding.EncodeToString(public[:])
privateStr := base64.StdEncoding.EncodeToString(private[:])
err = ioutil.WriteFile(cleanPath(path.Join(cleanPath(keyPath), "key.public")), []byte(publicStr), 0644)
lapi.Saved(false, "Cannot generate keys without deleting keys that already exist. Please choose a different directory or remove the existing keys.")
return
}
if os.IsNotExist(err) {
public, private, err := box.GenerateKey(rand.Reader)
if err == nil {
err = ioutil.WriteFile(cleanPath(path.Join(cleanPath(keyPath), "key.private")), []byte(privateStr), 0644)
publicStr := base64.StdEncoding.EncodeToString(public[:])
privateStr := base64.StdEncoding.EncodeToString(private[:])
err = ioutil.WriteFile(cleanPath(path.Join(cleanPath(keyPath), "key.public")), []byte(publicStr), 0644)
if err == nil {
lapi.Saved(true, "Key File Saved")
return
err = ioutil.WriteFile(cleanPath(path.Join(cleanPath(keyPath), "key.private")), []byte(privateStr), 0644)
if err == nil {
lapi.Saved(true, "Key File Saved")
return
} else {
lapi.Saved(false, err.Error())
return
}
} else {
lapi.Saved(false, err.Error())
return
}
} else {
lapi.Saved(false, err.Error())
return
}
}
lapi.Saved(false, err.Error())


Loading…
Cancel
Save