Commit Graph

339 Commits

Author SHA1 Message Date
Bo-Yi Wu
a41d4afc40
chore(protocol): improve IPv6 address. (#268)
* docs: improve documentation and configuration handling

- Clarify valid values for the IP protocol in usage messages for both main application and proxy settings

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

* test: improve IPv6 command execution tests

- Add a new test function `TestCommandWithIPv6` to check command execution with an IPv6 address
- Initialize test variables and expected output for the IPv6 command test
- Set up a `Plugin` struct with IPv6 host, user, port, key path, script, and command timeout for testing
- Verify that `plugin.Exec()` returns `nil` (no error) in the IPv6 test
- Assert that the output of the command execution matches the expected output in the IPv6 test

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

* test: enhance test suite and CI robustness

- Add support for IPv6 protocol in `TestCommandWithIPv6` test case in `plugin_test.go`

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

* update

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

* update

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

* update

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

* update

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

* update2

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

* update3

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

* update4

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

* update5

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

* update5

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

* update5

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

---------

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2024-01-21 09:27:49 +08:00
Bo-Yi Wu
91fd4f8071
chore: update golang.org/x/crypto to v0.18.0 in go.mod file
- Update golang.org/x/crypto from v0.17.0 to v0.18.0 in the go.mod file

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2024-01-11 20:53:31 +08:00
Bo-Yi Wu
b34fffdbd3
feat: update plugin functionality in main.go and plugin.go files
- Add a new flag to the main.go file
- Add a new field to the Plugin type in the plugin.go file
- Remove two lines from the plugin_test.go file

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2024-01-07 17:44:54 +08:00
Bo-Yi Wu
d217773bac
test: increase test coverage for SudoCommand function
- Add a test for the SudoCommand function

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2024-01-07 17:40:23 +08:00
Bo-Yi Wu
ae023d7aa6
chore: update sudoers file for improved security and permissions management
- Add `requiretty` to the `Defaults` in sudoers
- Allow `drone-scp` to run commands without password prompt

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2024-01-07 17:21:59 +08:00
Bo-Yi Wu
222545746b
chore: refactor build and deployment processes
- Add `sudo` to the apk add command in the lint workflow
- Add SSH server setup to the Makefile

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2024-01-07 17:13:16 +08:00
Bo-Yi Wu
a5f89304fd
chore: update golang.org/x/sys to v0.16.0 in go.mod file
- Update the version of `golang.org/x/sys` from `v0.15.0` to `v0.16.0` in the `go.mod` file

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2024-01-07 13:38:54 +08:00
Bo-Yi Wu
a9cfc0c134
chore: update external dependencies to latest versions
- Update the version of `github.com/appleboy/easyssh-proxy` from `v1.4.1-0.20231106031702-5666e2ea5156` to `v1.5.0`
- Update the version of `github.com/urfave/cli/v2` from `v2.26.0` to `v2.27.1`

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2024-01-01 13:53:45 +08:00
Bo-Yi Wu
13ba21acf6
chore: update dependencies to latest versions
- Update `github.com/urfave/cli` dependency from `v2.25.7` to `v2.26.0`
- Upgrade `golang.org/x/crypto` from `v0.14.0` to `v0.17.0`
- Bump `github.com/cpuguy83/go-md2man` from `v2.0.2` to `v2.0.3`
- Update `github.com/xrash/smetrics` to a newer commit
- Update `golang.org/x/sys` from `v0.14.0` to `v0.15.0`

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2023-12-26 13:33:32 +08:00
Bo-Yi Wu
e270b033d1
ci: update dependencies and workflows
- Update the Golang version in the lint workflow from `1.19-alpine` to `1.21-alpine`

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2023-12-26 13:29:44 +08:00
Bo-Yi Wu
aa9314a009
chore: add default user for enhanced security (#267)
- Add a new `.hadolint.yaml` configuration file with specific rule ignores
- Update the Dockerfile to install `ca-certificates` without a fixed version
- Add commands to create a `deploy` user and group with UID and GID `1000`, set home directory, and set ownership
- Set the Docker container to run as the `deploy` user with UID and GID `1000`

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2023-12-26 13:29:22 +08:00
Bo-Yi Wu
037e0231ac
chore: update dependencies to latest versions
- Update the `go-version` in the lint.yml file from `^1` to `^1.21`
- Update the version of `github.com/appleboy/easyssh-proxy` in the go.mod file from `v1.4.0` to `v1.4.1-0.20231106031702-5666e2ea5156`
- Update the version of `golang.org/x/crypto` in the go.mod file from `v0.10.0` to `v0.14.0`
- Update the version of `golang.org/x/sys` in the go.mod file from `v0.9.0` to `v0.14.0`

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2023-11-06 11:20:51 +08:00
Bo-Yi Wu
ddf1b161aa
chore: refactor GitHub Actions workflows
- Fix a typo in the cron expression for the codeql.yml workflow
- Change the language specification from ['go'] to ['go'] in the codeql.yml workflow
- Change the version specification from 'v*' to 'v*' in the docker.yml workflow
- Change the branch specification from 'master' to 'master' in the docker.yml workflow
- Change the go-version specification from '^1' to '^1.21' in the docker.yml workflow
- Remove the name "Set up QEMU" in the docker.yml workflow
- Remove the name "Set up Docker Buildx" in the docker.yml workflow
- Remove the name "Login to Docker Hub" in the docker.yml workflow
- Remove the name "Login to GitHub Container Registry" in the docker.yml workflow
- Remove the name "Docker meta" in the docker.yml workflow
- Remove the name "Build and push" in the docker.yml workflow
- Change the version specification from '*' to '*' in the goreleaser.yml workflow
- Remove the name "Checkout" in the goreleaser.yml workflow
- Remove the name "Setup go" in the goreleaser.yml workflow
- Change the go-version specification from '^1' to '^1' in the goreleaser.yml workflow
- Remove the name "Run GoReleaser" in the goreleaser.yml workflow
- Change the go-version specification from '^1' to '^1' in the lint.yml workflow

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2023-10-25 10:52:46 +08:00
Bo-Yi Wu
32510c86bf
feat: implement and test all environment variables functionality (#264)
- Add a new flag `allenvs` to pass all environment variables to the shell script
- Implement the `AllEnvs` functionality in the `exec` function
- Add a new function `findEnvs` to find all environment variables with specified prefixes
- Add tests for the `findEnvs` function and the `AllEnvs` functionality
2023-07-23 09:41:09 +08:00
appleboy
80cecf1ed3 refactor: improve code clarity and logging functionality
- Add a comment to clarify the purpose of the `format` function
- Add a comment to clarify the purpose of the `log` function
- Modify the `log` function to always print the message, removing the previous conditional statement

Signed-off-by: appleboy <appleboy.tw@gmail.com>
2023-07-23 07:30:08 +08:00
appleboy
c7dd9890fa chore: improve performance and test coverage across OSs
- Update easyssh-proxy dependency from v1.3.11 to v1.4.0

Signed-off-by: appleboy <appleboy.tw@gmail.com>
2023-06-23 23:43:57 +08:00
Yoan Tournade
905bb4cb1a
chore: allows to specify IP protocol (#261)
* Allows to specify IP protocol, including IPv4 only

* Add tests forcing IPv4 or IPv6
2023-06-23 16:45:44 +08:00
Bo-Yi Wu
066b72ac09 chore: update dependencies and improve test accuracy
- Update urfave/cli/v2 from v2.25.5 to v2.25.7
- Update golang.org/x/crypto from v0.9.0 to v0.10.0
- Update golang.org/x/sys from v0.8.0 to v0.9.0 (indirect)

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2023-06-21 16:25:15 +08:00
Bo-Yi Wu
b33ad90151 chore: improve API efficiency and test robustness
- Update ca-certificates version from `20220614-r4` to `20230506-r0`

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2023-06-04 16:46:53 +08:00
Bo-Yi Wu
c4f4d0f112 chore: improve performance and update dependencies
- Add `bin` to .gitignore
- Change output path for the executable in Makefile
- Update `github.com/stretchr/testify` to v1.8.4
- Update `github.com/urfave/cli/v2` to v2.25.5

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2023-06-04 16:44:10 +08:00
appleboy
8b81da22bc chore: update dependencies and improve test tolerance
- Update `github.com/urfave/cli/v2` dependency from `v2.25.3` to `v2.25.4`
- Update `golang.org/x/crypto` dependency from `v0.8.0` to `v0.9.0`

Signed-off-by: appleboy <appleboy.tw@gmail.com>
2023-05-29 21:07:06 +08:00
appleboy
ba70ad67ca ci: improve release process and test robustness
- Add extra_files with .xz glob pattern to .goreleaser.yaml

Signed-off-by: appleboy <appleboy.tw@gmail.com>
2023-05-06 08:16:02 +08:00
appleboy
73fa4739e3 chore: optimize codebase with latest library updates
- Update `github.com/urfave/cli/v2` from `v2.25.1` to `v2.25.3`
- Update `golang.org/x/sys` from `v0.7.0` to `v0.8.0` (indirect)

Signed-off-by: appleboy <appleboy.tw@gmail.com>
2023-05-06 08:00:17 +08:00
appleboy
0a721bdfff build: optimize binary size and improve test accuracy
- Add a post-build hook to compress the generated binary with `xz` at level 9 compression

Signed-off-by: appleboy <appleboy.tw@gmail.com>
2023-05-06 07:57:07 +08:00
appleboy
a7c7568d70 feat: improve API usage and test coverage across platforms
- Add an option to include extra pre-existing files in the release with a specified file format (`.xz`)

Signed-off-by: appleboy <appleboy.tw@gmail.com>
2023-05-06 07:51:54 +08:00
appleboy
bc8c96633a chore: improve API usage and test accuracy
- Add "strconv" import
- Update app copyright to use the current year

Signed-off-by: appleboy <appleboy.tw@gmail.com>
2023-05-01 11:56:09 +08:00
Bo-Yi.Wu
30b18520ed refactor(setting): reorder format. 2023-04-15 06:25:31 +08:00
Bo-Yi Wu
67a2631616 docs: improve clarity of Usage message in main.go
- Modify the `Usage` message in main.go

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2023-04-13 09:48:46 +08:00
Alexey Smirnov
fdc4c8de43
fix: example with secrets (#178) 2023-04-13 09:39:43 +08:00
Bo-Yi Wu
49542638c6
refactor: set default environment variables format in plugin (#253)
- Add `INPUT_ENVS_FORMAT` to the list of environment variables in `main.go`
- Define `envsFormat` variable in `plugin.go`
- Add default value for `Config.EnvsFormat` in `plugin.go` `Exec()` function

fix https://github.com/appleboy/drone-ssh/pull/235
2023-04-13 09:32:31 +08:00
Vladimir Sigalkin
6464d9999f
chore: flexible configuration of environment value transfer (#235)
**Reason:**
I have to use drone-ssh to work with Windows SSH. Initially, drone-ssh is written so that it transmits environment variables through the `export` command. Which makes it unsuitable for working with Power Shell.

**Solution:**
I have added a new option to configure environment variable commands formatting, with default value: `export {NAME}={VALUE}`. When I use drone-ssh with PowerShell I set this option like this: `$env:{NAME} = {VALUE}`.
2023-04-13 09:13:07 +08:00
Bo-Yi Wu
4aabfc90dd chore: upgrade Dependencies to Latest Versions
- Upgrade easyssh-proxy from v1.3.9 to v1.3.10
- Upgrade testify from v1.8.1 to v1.8.2
- Upgrade crypto from v0.7.0 to v0.8.0
- Upgrade sys from v0.6.0 to v0.7.0

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2023-04-13 09:09:37 +08:00
Bo-Yi Wu
b9cfca60e9
refactor: standardize environment variables naming conventions (#252)
- Modify the `EnvVars` slice to include `INPUT_` prefix when needed
- Remove unused environment variables from the `EnvVars` slice
- Update the `EnvVars` slice to include `PROXY_` prefix when needed
- Modify the `EnvVars` slice to include `PLUGIN_SSH_CIPHERS` as `PROXY_SSH_CIPHERS`
- Modify the `EnvVars` slice to include `PLUGIN_PROXY_USE_INSECURE_CIPHER` as `PROXY_SSH_USE_INSECURE_CIPHER`
- Modify the `EnvVars` slice to include `PLUGIN_PROXY_FINGERPRINT` as `PROXY_SSH_FINGERPRINT`
- Remove the environment variable `PROXY_HOST`
- Modify the `EnvVars` slice to include `PLUGIN_DEBUG` as `INPUT_DEBUG`

* https://github.com/appleboy/ssh-action/issues/53#issuecomment-1184700432
* https://github.com/appleboy/ssh-action/issues/32#issuecomment-1184700363
* https://github.com/appleboy/ssh-action/issues/213
2023-04-13 09:08:12 +08:00
Bo-Yi Wu
a8d30dc133
feat: refactor code for parallel execution on multiple hosts (#249)
- Add `trimValues` function for cleaning up slice values
- Remove unused `wg.Done()` call
- Modify `Exec` function to launch goroutines for each host in `Config.Host`
- Add test for `ScriptStop` with multiple hosts and sync mode

refer to: https://github.com/appleboy/ssh-action/issues/233
2023-04-04 16:56:50 +08:00
Bo-Yi.Wu
f733bb5ebf chore: remove Hadolint configuration file
- Delete the `.hadolint.yaml` file.

Signed-off-by: Bo-Yi.Wu <appleboy.tw@gmail.com>
2023-04-04 15:39:10 +08:00
Bo-Yi.Wu
b0ddeb9413 chore: update container security measures
- Add Open Container Initiative labels for image source, description, and licenses
- Update `apk` command to include specific version of `ca-certificates`

Signed-off-by: Bo-Yi.Wu <appleboy.tw@gmail.com>
2023-04-04 15:38:42 +08:00
Bo-Yi Wu
8c5d17d83d chore: refactor release process to use main.Version flag
- Change the `drone-ssh` version flag to `main.Version` in `.goreleaser.yaml`

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2023-03-29 08:59:31 +08:00
Bo-Yi Wu
050e0e6efd docs: use ghcr.io/appleboy/drone-ssh image for SSH connections
- Update the `image` field to use `ghcr.io/appleboy/drone-ssh` in DOCS.md
- Update the `image` field to use `ghcr.io/appleboy/drone-ssh` in README.md

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2023-03-28 14:43:00 +08:00
Bo-Yi Wu
f01d5d9454 chore(deps): update go.sum 2023-03-28 14:23:20 +08:00
Bo-Yi.Wu
c004469746 ci: upgrade setup-go action and remove release binary action
- Remove release binary github action
- Upgrade setup-go action from v3 to v4 in docker, goreleaser, and lint github actions

Signed-off-by: Bo-Yi.Wu <appleboy.tw@gmail.com>
2023-03-27 22:02:48 +08:00
Bo-Yi.Wu
bc2dac669a chore: refactor installation command for drone-ssh using go install
- Update `drone-ssh` installation command to use `go install` instead of `go get`

Signed-off-by: Bo-Yi.Wu <appleboy.tw@gmail.com>
2023-03-27 22:01:11 +08:00
Albert Wang
541508632d
chore: remove dotenv autoloading (#243) 2023-03-27 21:56:04 +08:00
Bo-Yi.Wu
22cd751b47 chore: update third-party libraries for improved security and performance
- Update urfave/cli to version 2.25.1
- Update golang.org/x/crypto to version 0.7.0
- Update golang.org/x/sys to version 0.6.0 (indirect)

Signed-off-by: Bo-Yi.Wu <appleboy.tw@gmail.com>
2023-03-27 21:52:44 +08:00
Bo-Yi.Wu
5a6a923356 build: configure cross-platform builds with Goreleaser
- Add a new file `.goreleaser.yaml`
- Configure builds for multiple operating systems and architectures
- Set flags and ldflags for the builds
- Add a binary name template for the builds
- Add an archive format
- Add a checksum template
- Add a snapshot template

Signed-off-by: Bo-Yi.Wu <appleboy.tw@gmail.com>
2023-03-27 21:51:52 +08:00
Bo-Yi Wu
1a95b5f1b3
chore(auth): allow use password and key at same time (#240) 2023-02-28 17:04:39 +08:00
Bo-Yi Wu
d0ed2bb2fb chore(docker): support multiple platform 2023-02-27 14:01:12 +08:00
Bo-Yi.Wu
b2a60a2fec chore(CI): upgrade build push actions
Signed-off-by: Bo-Yi.Wu <appleboy.tw@gmail.com>
2023-02-24 09:35:20 +08:00
Bo-Yi.Wu
7c7619ebbc chore(deps): upgrade dependency.
Signed-off-by: Bo-Yi.Wu <appleboy.tw@gmail.com>
2023-02-24 09:33:41 +08:00
dependabot[bot]
fc62fb377c
chore(deps): bump hadolint/hadolint-action from 3.0.0 to 3.1.0 (#225)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-01 16:27:36 +08:00
Bo-Yi Wu
808373f717 docs: fix wrong link 2023-02-01 16:27:18 +08:00