1
0
mirror of https://github.com/libssh2/libssh2.git synced 2025-11-17 04:22:32 +03:00
Commit Graph

34 Commits

Author SHA1 Message Date
Viktor Szakats
f97fb271e3 scripts: fix shellcheck SC2046 warnings
Also:
- use more `--` end-of-options markers.
- checksrc.sh: use literal quotes.

Closes #1739
2025-11-10 19:06:10 +01:00
Viktor Szakats
557611f92b checksrc: update, update local config, fix toctou in examples
Closes #1719
2025-10-14 03:29:05 +02:00
Viktor Szakats
4f9e6e0bfb REUSE: add copyright headers to more files, and .gitignore updates
Also:
- rename a spellcheck file to match curl.
- editorconfig: fix line width.
- editorconfig: make it use UTF-8.
- editroconfig: apply some rules to all files.
- .gitignore: drop dupe, drop `.DS_Store` (not created by this repo),
   sort.
- .gitignore: add for tests executables.

Closes #1718
2025-10-13 13:35:25 +02:00
Viktor Szakats
e62a72b22f ci/GHA: move CI checks to Linux, other CI tweaks
Also:
- merge CI check and shellcheck jobs into a single one.
  To share the same shellcheck version and less overhead.
- use `set -eu` in more scripts.
- make sure CI scripts run from any cwd.
  To make it easy to run them on local machine.
- minor tidy-ups.

Closes #1618
2025-07-13 11:21:39 +02:00
Viktor Szakats
694b9d964b cmake: add linter, fix issues
Ref: https://cmake-format.readthedocs.io/en/latest/cmake-lint.html
Ref: https://github.com/cheshirekow/cmake_format

Closes #1610
2025-06-11 07:09:10 +02:00
Viktor Szakats
96cbe61896 ossfuzz: fix picky compiler warnings, make it pass checksrc
- fix compiler warnings.
- make it pass `checksrc`.
- fix shell `set -u` errors.
  Follow-up to 5012442850 #901
- REUSE: tidy up ossfuzz files.

Cherry-picked from #1484
Closes #1526
2025-01-30 23:36:39 +01:00
Viktor Szakats
7e1c6be12f checksrc: sync with curl
Check spaces around logical AND operator.

Closes #1474
2024-10-21 23:34:23 +02:00
Viktor Szakats
1117b677a0 checksrc: update, check all sources, fix fallouts
update from curl:
cff75acfec/scripts/checksrc.pl

Closes #1457
2024-09-28 11:41:52 +02:00
Viktor Szakats
c6625707b9 os400: fix shellcheck warnings in scripts
- use `$()` instead of backticks, and re-arrange double-quotes inside.
- add missing `|| exit 1` to `cd` calls. (could be dropped by using `set -eu`.)
- add `-n` to a few `if`s.
- shorten redirections by using `{} >` (as shellcheck recommended).
- silence warnings where variables were detected as unused (SC2034).
- a couple misc updates to silence warnings.
- switch to bash shebang for `-ot` feature.
- split two lines to unbreak syntax highlighting in my editor. (`$(expr \`, `$(dirname \`)

Also enable CI checks for OS/400 shell scripts.

Ref: d88b9bcdaf
Closes #1358
2024-04-11 07:53:42 +00:00
Viktor Szakats
d88b9bcdaf ci: add shellcheck job and script
Add FIXME for OS/400 scripts.

Cherry-picked from #1358
2024-04-10 00:49:55 +00:00
Viktor Szakats
fc24735f61 ci/spellcheck: delete redundant option [ci skip]
`--check-hidden` not necessary when passing filenames explicitly.

Follow-up to a79218d3a0
2023-12-14 20:20:39 +00:00
Viktor Szakats
8cd473c930 checksrc: sync with curl
Closes #1272
2023-12-06 01:13:15 +00:00
Viktor Szakats
06fd721f08 appveyor: YAML/PowerShell formatting, shorten variable name
- use single-quotes in yaml and PowerShell.

- shorten a variable name.

- use indentation 2 for scripts.

- use C else-style in PowerShell.

Closes #1200
2023-10-02 12:41:22 +00:00
Viktor Szakats
a79218d3a0 ci: add spellcheck (codespell)
Also rename a variable in `src/os400qc3.c` to avoid a false positive.

Cherry-picked from #1175
2023-08-23 10:55:51 +00:00
Viktor Szakats
a95d401f1f checksrc: fix spelling in comment [ci skip] 2023-08-20 00:24:59 +00:00
Viktor Szakats
3d309f9b8d checksrc: modernise perl file open
Use regular variables and separate file open modes from filenames.

Suggested by perlcritic

Copied from 7f669aa0f1
Copied from https://github.com/curl/trurl/commit/f2784a9240f47ee28a845
2023-06-23 16:30:41 +00:00
Daniel Stenberg
f6aa31f48f provide SPDX identifiers
- All files have prominent copyright and SPDX identifier
- If not embedded in the file, in the .reuse/dep5 file
- All used licenses are in LICENSES/ (not shipped in tarballs)
- A new REUSE CI job verify that all files are OK

Assisted-by: Viktor Szakats

Closes #1084
2023-06-07 08:18:55 +02:00
Viktor Szakats
d67a91aa10 checksrc: switch to dot file
Closes #1052
2023-05-30 17:24:28 +00:00
Viktor Szakats
1c9323416c checksrc: verify label indent, fix fallouts
Also update two labels to match the rest of the source.

checksrc update credit: Emanuele Torre @emanuele6

Ref: https://github.com/curl/curl/pull/11134

Closes #1042
2023-05-18 14:07:01 +00:00
Viktor Szakats
b87fbc91cb checksrc.sh: fix it to run from any current directory
Also silence a shellcheck warning.

Cherry-picked from #1017
2023-05-03 01:49:46 +00:00
Viktor Szakats
d964289e54 checksrc: sync with curl
There were no new issues detected.

Cherry-picked from #1017
2023-05-03 01:35:16 +00:00
Viktor Szakats
738cbf5503 docker-bridge.ps1: use native newlines
Also add a shebang and exec flag to ease testing/handling on *nix.
PowerShell accepts both LF and CRLF.

Cherry-picked from #1017
2023-05-03 01:08:33 +00:00
Viktor Szakats
ccac522260 checksrc: update and apply fixes
Update to latest revision and fix new issues detected.

Closes #1014
2023-04-28 14:19:48 +00:00
Viktor Szakats
f36edf94e7 ci: convert docker-bridge.bat to shell script
Convert `ci/appveyor/docker-bridge.bat` to a POSIX shell script.

Also bump the tunnel to use ed25519 (was RSA-2048).

Closes #997
2023-04-28 13:58:26 +00:00
Viktor Szakats
a459a25302 tests: improve running tests
TL;DR: Sync test builds between autotools and CMake. Sync sshd
configuration between Docker and non-Docker fixtures. Bump up
sshd_config for recent OpenSSH releases.

This also opens up the path to have non-Docker tests that use a
local sshd process. Though sshd is practically unusable on Windows
CI machines out of the box, so this will need further efforts.

Details:

- cmake: run sshd fixture test just like autotool did already.

- sync tests and their order between autotools and CMake.

  It makes `test_aa_warmup` the first test with both.

- cmake: load test lists from `Makefile.am`.

  Needed to update the loader to throw away certain lines to keep the
  converted output conform CMake syntax. Using regexp might be an
  alternative way of doing this, but couldn't make it work.

- cmake: use the official way to configure test environment variables.
  Switch to syntax that's extendable.

- cmake: allow to run the same test both under Docker and sshd fixture.

  Useful for testing the sshd fixture runner, or how the same test
  behaves in each fixture.

- update test fixture to read the username from `USER` envvar instead of
  using the Dockfile-specific hardwired one, when running outside Docker.

- rework `ssh2.sh` into `sshd_fixture.sh`, to:

  - allow running any tests (not just `test_ssh2`).
  - configure Docker tests for running outside Docker.
  - fixup `SSHD` path when running on Windows (e.g. in AppVeyor CI).
    Fixes: `sshd re-exec requires execution with an absolute path`
  - allow overriding `PUBKEY` and `PRIVKEY` envvars.
  - allow overriding `ssh_config` via `SSHD_FIXTURE_CONFIG`.

- prepare support for running multiple tests via sshd_fixture.

  Add a TAP runner for autotools and extend CMake logic. The TAP runner
  loads the test list from `Makefile.am`.

  Notice however that on Windows, `sshd_fixture.sh` is very flaky with
  GitHub Actions. And consistently broken for subsequent tests in
  AppVeyor CI:
    'libssh2_session_handshake failed (-43): Failed getting banner'

  Another way to try is a single sshd instance serving all tests.
  For CMake this would probably mean using an external script.

- ed25519 test keys were identical for auth and host. Regenerate the
  auth keypair to make them distinct.

- sync the sshd environment between Docker and sshd_fixture.

  - use common via `openssh_server/sshd_config`.
  - accept same auth keys.
  - offer the same host keys.
  - sync TrustedUserCAKeys.
  - delete now unused keypairs: `etc/host*`, `etc/user*`.
  - bump up startup delay for Windows (randomly, to 5 secs, from 3).
  - delete `UsePrivilegeSeparation no` to avoid deprecation warnings.
    `command-line line 0: Deprecated option UsePrivilegeSeparation`
  - delete `Protocol 2` to avoid deprecation warnings.
    It has been the default since OpenSSH 3.0 (2001-11-06).
  - delete `StrictModes no` (CI tests work without it, Docker tests
    never used it).

- bump `Dockerfile` base image to `testing-slim` (from `bullseye-slim`).

  It needed `sshd_config` updates to keep things working with
  OpenSSH 9.2 (compared to bullseye's 8.4).

  - replace `ChallengeResponseAuthentication` alias with
    `KbdInteractiveAuthentication`.
    The former is no longer present in default `sshd_config` since
    OpenSSH 8.7 (2021-08-20). This broke the `Dockerfile` script.
    The new name is documented since OpenSSH 4.9 (2008-03-31)

  - add `PubkeyAcceptedKeyTypes +ssh-rsa,ssh-dss,ssh-rsa-cert-v01@openssh.com`
    and `HostKeyAlgorithms +ssh-rsa`.

    Original-patch-by: Eric van Gyzen (@vangyzen on github)
    Fixes #691

    There is a new name for `PubkeyAcceptedKeyTypes`:
       `PubkeyAcceptedAlgorithms`.
    It requires OpenSSH 8.5 (2021-03-03) and breaks some envs so we're
    not using it just yet.

- drop `rijndael-cbc@lysator.liu.se` tests and references from config.

  This is a draft alias for `aes256-cbc`. No need to test it twice.
  Also this alias is no longer recognized by OpenSSH 8.5 (2021-03-03).

- update `mansyntax.sh` and `sshd_fixture.sh` to not rely on `srcdir`.

  Hopefully this works with out-of-tree builds.

- fix `test_read_algos.test` to honor CRLF EOLs in their inputs
  (necessary when running on Windows.)

- fix `test_read_algos.test` to honor `EXEEXT`. Might be useful when
  running tests under cross-builds?

- `test_ssh2.c`:

  - use libssh2 API to set blocking mode. This makes it support all
    platforms.
  - adapt socket open timeout logic from `openssh_fixture.c`.
    Sadly this did not help fix flakiness on GHA Windows.

- tests: delete unused C headers and variable initialization.

- delete unused test files: `sshd_fixture.sh.in`, `sshdwrap`,
  `etc/sshd_config`.

  Ref: cf80f2f4b5

- autotools: delete stray `.c` test sources from `EXTRA_DIST` in tests.

- `tests/.gitignore`: drop two stray tests.

- autotools: fix passing `SSHD` containing space (Windows needs this).

- autotools: sort `EXTRA_DIST` in tests.

- cmake: fix to add `test_ssh2` to `TEST_TARGETS`.

- fix `authorized_key` order in `tests/gen_keys.sh`.

- silence shellcheck warning in `ci/checksrc.sh`.

- set `SSHD` for autotools on GitHub Actions Windows. [skipped]

  Auto-detection doesn't work (maybe because sshd is installed via
  Git for Windows and we're using MSYS2's shell.)

  It enables running sshd fixture (non-Docker) tests in these jobs.

  I did not include this in the final patch due to flakiness:
  ```
  Connection to 127.0.0.1:4711 attempt #0 failed: retrying...
  Connection to 127.0.0.1:4711 attempt #1 failed: retrying...
  Connection to 127.0.0.1:4711 attempt #2 failed: retrying...
  Failure establishing SSH session: -43
  ```

  Can be enabled with:
  `export SSHD='C:/Program Files/Git/usr/bin/sshd.exe'`

Closes #996
2023-04-24 21:28:28 +00:00
Viktor Szakats
5d399233d8 checksrc: fix EQUALSNULL warnings
`s/([a-z0-9._>*-]+) == NULL/!\1/g`

Closes #964
2023-04-15 02:46:09 +00:00
Viktor Szakats
1b0c93b755 checksrc: fix NOTEQUALSZERO warnings
Closes #963
2023-04-14 19:16:27 +00:00
Viktor Szakats
8b4387d0dc checksrc: fix SIZEOFNOPAREN warnings
`s/sizeof ([a-z0-9._>*-]+)/sizeof(\1)/g`

Closes #962
2023-04-14 19:15:18 +00:00
Viktor Szakats
4b800182c5 checksrc: update and fix warnings (#890)
Update from:
5fec927374/scripts/checksrc.pl

- suppress these new checks:

  - EQUALSNULL: 320 warnings
  - NOTEQUALSZERO: 142 warnings
  - TYPEDEFSTRUCT: 16 warnings

  We can enabled them in the future.

- fix all other new ones.

- also fix whitespace in two `NMakefile` files.
2023-03-28 09:37:46 +02:00
Viktor Szakats
1d9af00609 tidy-up: fix typos (#886)
detected by codespell 2.2.4.
2023-03-27 19:26:58 +02:00
Marc Hoersken
94bd3d87c5 Remove OSSFuzz integration which was replaced with CIFuzz (#756)
Confirmed-by: Max Dymond
2022-10-18 20:28:30 +02:00
Marc Hoersken
fee3125b3b CI/appveyor: run SSH server for tests on GitHub Actions (#607)
No longer rely on DigitalOcean to host the Docker container.

Unfortunately we require a small dispatcher script that has
access to a GitHub access token with scope repo in order to
trigger the daemon workflow on GitHub Actions also for PRs.

This script is hosted by myself for the time being until GitHub
provides a tighter scope to trigger the workflow_dispatch event.
2021-05-28 08:52:27 +02:00
Gabriel Smith
ee199144fe ci: Swap from Travis to Github Actions (#581)
Files: ci files

Notes:
Move Linux CI using Github Actions

Credit:
Gabriel Smith, Marc Hörsken
2021-04-30 16:10:52 -07:00
Etienne Samson
1adb24fd07 Add a LINT option to CMake (#372)
* ci: make style-checking available locally

* cmake: add a linting target

* tests: check test suite syntax with checksrc.pl
2021-02-02 10:28:28 -08:00