summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2023-10-04Release awwan v0.8.0 (2023-10-04)v0.8.0Shulhan
This release add support for encryption, with two new commands "encrypt" and "decrypt" for encrypting and decrypting file with RSA private key. The awwan command also can read encrypted environment file with the name ".awwan.env.vault", so any secret variables can stored there and the script that contains '{{.Val "..."}}' works as usual. Any magic put "#put" also can copy encrypted file without any changes, as long as the source file with ".vault" extension exist. For environment where awwan need to be operated automatically, for example in build system, awwan can read the private key's passphrase automatically from the file ".ssh/awwan.pass". === Bug fixes * all: do not expand environment during parseScript * all: fix #require does not get executed on the same start * _www: fix execute request that still use "begin_at" and "end_at" === Enhancements * all: make .Vars, .Val, and .Vals panic if values is empty * all: print any path relative to base directory * all: move field bufout and buferr out of httpServer struct
2023-10-04go.mod: update share moduleShulhan
2023-09-30testdata/decrypt-wrong-privatekey: replace symlink on .awwan.env.vaultShulhan
On new cloned repository, running the test will fail when using symlink, 0 - Decrypt: DecryptOaep: crypto/rsa: decryption error 0 + Decrypt: open testdata/decrypt-wrong-privatekey/.awwan.env.vault: no such file or directory
2023-09-30all: add option to bypass input passphrase from terminalShulhan
In the environment where passphrase cannot be inputted manually, for example, automatic integration or deployment, we need some mechanism where awwan can be executed to copy or decrypt the encrypted file. The option is by reading plain passphrase from file named "awwan.pass" inside the ".ssh" directory. If its exists and not empty, awwan will not prompt for passphrase from terminal, instead use the content of that file as passhprase.
2023-09-29all: update README related to support for encryptionShulhan
While at it, also update the documentation index, remove finished TODO, add and expand items in TODO to be more descriptive.
2023-09-28_www: fix execute request that still use "begin_at" and "end_at"Shulhan
While at it, reformat the TypeScript files using prettier v3.0.3.
2023-09-28internal: replace esbuild api.Build with api.BuildContextShulhan
Using api.BuildContext [1] is more efficient than building again because some of the data from the previous build is cached and can be reused if the original files haven't changed since the previous build. While at it, we update the github.com/evanw/esbuild module to latest release. [1] https://esbuild.github.io/api/#rebuild
2023-09-28all: move field bufout and buferr out of httpServer structShulhan
Those fields are used on each HTTP request to /awwan/api/execute, which make them not safe if two or more requests processed at the same time.
2023-09-28all: create struct to handle HTTP serverShulhan
All fields that use to serve HTTP API now moved inside one struct, including memfsBase, bufout, and buferr.
2023-09-28all: split type fsRequest to its separate fileShulhan
2023-09-28all: rename http_api.go to http_server.goShulhan
We will move all fields related to HTTP server into one struct later.
2023-09-27go.mod: update share to fix error checkingShulhan
2023-09-27all: print any path relative to base directoryShulhan
This is to minimize log length in stdout and stderr, which make it more readable.
2023-09-27all: add tests for local with empty and invalid passphraseShulhan
While at it, rename the script for testing encrypted value to allow other tests without encryption later.
2023-09-27all: make .Vars, .Val, and .Vals panic if values is emptyShulhan
This is to prevent copying or executing command with value that are not defined or typo which make the result empty and may result in undefined behaviour. For example if we have "app_dir = /data/app" and command in the script that remove that directory recursively, sudo rm -r {{.Val "::app_dir}}/bin will result removing "/bin" entirely.
2023-09-27all: change default path for private key to be located under .ssh directoryShulhan
Using hidden file (with "." prefix in name) cluttering the workspace directory. Since we already have ".ssh" as indicator of workspace, we should use it, the same principal that ~/.ssh/ store user's private key.
2023-09-26go.mod: update share moduleShulhan
This fix "go install" on cmd/awwan that does build with the replace directive in share module which cause awwan not working properly.
2023-09-26testdata: rename "encrypt" to "local"Shulhan
We change the directory name because the "encrpyt" is not specific to encryption only but only for local.
2023-09-26all: test local put without encrypted fileShulhan
2023-09-26all: add prefix "awwan." to the name of temporary directoryShulhan
Each time the new session is created in local or remote, it will create new temporary directory. Previously, the name of temporary directory is random 16 characters and numbers. To distinguish this directory with others, we add prefix "awwan." to the name.
2023-09-26all: move ssh and sftp client into separate structShulhan
The sshClient struct wrap the raw SSH connection and SFTP connection, and provide methods get, put, sudoGet, sudoPut, mkdir, and rmdirAll.
2023-09-26all: call loadEnvFromPaths inside newSessionShulhan
Since loadEnvFromPaths always called after NewSession, and it is part of session initialization, we can move the call inside the NewSession to minimize duplicate code.
2023-09-26all: move fields and methods related to encryption to struct cryptoContextShulhan
The cryptoContext contains the default hash, loaded privateKey, dummy terminal, base directory, and default label; all of those fields are required for encryption and decryption. The cryptoContext have three methods: encrypt, decrypt, and loadPrivateKey. By moving to separate struct the cryptoContext instance can be shared with Session.
2023-09-26all: make the magic word "#put" able to copy encrypted fileShulhan
When issuing "#put:" or "#put!" command in the script, if the input file is not exist it will check for the encrypted file, the one with ".vault" extension. If it exists, the encrypted file will be used as input for copy operation.
2023-09-23all: move the parseTemplate as method of Session generateFileInputShulhan
2023-09-23all: merge some functions into NewScript and ParseScriptShulhan
Previously, we have NewScriptForLocal, NewScriptForRemote, ParseScriptForLocal, and ParseScriptForRemote. Since script for local and remote actually the same and since we remove applying environment variables at 858c26d3d940 on local, we can merge them into NewScript and ParseScript.
2023-09-23all: allow empty passphrase when running commandShulhan
Even thought the private key exist, not every command execution require private key. In case it is required and private key is nil, it will return an error during decryption.
2023-09-23go.mod: update all dependenciesShulhan
2023-09-22all: implement reading encrypted awwan environment ".awwan.env.vault"Shulhan
Upon executing "local" or "play" comman, awwan now read the encrypted environment file .awwan.env.vault. The encrypted environment file is generated using "awwan encrypt" command.
2023-09-22all: update the comment on Request typeShulhan
This move the comment related to non-exported fields inside the struct instead of top.
2023-09-22all: split the decrypt into separate functionShulhan
The decrypt function accept the private key and cipher text to be decrypted. This will allow the function to be used by other methods later, not only by Decrypt method.
2023-09-22all: make the private key loaded when Awwan initializedShulhan
Instead of loading private key on Encrypt or Decrypt methods, load it when the Awwan instance created.
2023-09-22doc: fix comment related to awwan README file nameShulhan
2023-09-21all: rename file range to line_range to match with its typeShulhan
The type name is lineRange so the file name should be line_range, not range.
2023-09-21all: return the encrypted file in Encrypt methodShulhan
This allow the caller of Encrypt know the path to encrypted file.
2023-09-20all: replace rsa.Decrypt/EncryptOAEP with libcrypto.Decrypt/EncryptOaepShulhan
The rsa.EncryptAOEP function has a maximum message size that they can encrypt (public key size - 2*hash.Size - 2). To fix this limitation we replace them with the one in libcrypto that extend the functions to allow encrypting and decrypting a larger message.
2023-09-20cmd/awwan: implement command to decrypt file using private keyShulhan
The "decrypt" command accept single argument, a file to be decrypted. Its reverse the "encrypt" output to get the plain text back.
2023-09-20all: implement method to decrypt file using private keyShulhan
The Decrypt method decrypt the file using private key from file "{{.BaseDir}}/.awwan.key". The encrypted file must have extension ".vault", otherwise it will return an error. The decrypted file output will be written in the same directory without the ".vault" extension in filePlain.
2023-09-20all: remove rand.SeedShulhan
The latest ascii.Random use "cryto/rand", so there is no need to call rand.Seed.
2023-09-20cmd/awwan: implement command to encrypt fileShulhan
The encrypt command accept single argument, the file to be encrypted.
2023-09-20all: add method Encrypt to AwwanShulhan
The Encrypt method encrypt the file using private key from file "{{.BaseDir}}/.awwan.key". The encrypted file output will be on the same file path with ".vault" extension.
2023-09-17Makefile: replace linter golangci-lintShulhan
The golangci-lint become unusable. It does not provide any useful hints on how to write better Go code. This changes replace golangci-lint with go vet, fieldalignment and shadow from x/tools, and revive. The fieldalignment tool provide hints on better struct size. The shadow tool provide hints on overwriting or shadowed variables. The revive tool provide hints on many code analysis that does not covered by go vet, fieldalignment, and shadow.
2023-09-17go.mod: update go version to 1.20 and dependenciesShulhan
2023-09-06all: remove unused parameter isLocal on parseScriptShulhan
2023-09-04internal: update embedded memfs contentShulhan
2023-09-04go.mod: update share moduleShulhan
The latest update on share module contains refactoring on lib/ssh.
2023-09-04all: fix #require does not get executed on the same start positionShulhan
2023-09-04all: do not expand environment during parseScriptShulhan
Environment variables in the script may only expanded by shell on remote not always on local.
2023-05-14Release awwan v0.7.0 (2023-05-14)v0.7.0Shulhan
=== Breaking changes * all: changes the line number arguments for "local" and "play" command === Chores * all: convert README from Asciidoc to Markdown * all: move code for development to package internal * all: add configuration for golangci-lint * all: move _doc to directory _www * go.mod: set the Go module version to 1.19
2023-05-14all: convert README from Asciidoc to MarkdownShulhan
I use two remote repositories: GitHub and SourceHut. GitHub support rendering README using asciidoc while SourceHut not. This cause the repository that use README.adoc rendered as text in SourceHut which make the repository page less readable. Also, the pkg.go.dev now render README but only support Markdown. Since we cannot control the SourceHut and go.dev, the only option is to support converting Markdown in ciigo so I can write README using Markdown and the rest of documentation using Asciidoc.