Skip to content

perl: harden external command invocations - #21097

Closed
vszakats wants to merge 18 commits into
curl:masterfrom
vszakats:perlsys
Closed

vszakats wants to merge 18 commits into
curl:masterfrom
vszakats:perlsys

Conversation

@vszakats

@vszakats vszakats commented Mar 25, 2026 •

Copy link
Copy Markdown
Member

In adddocsref.pl, checksrc-all.pl, singleuse.pl and tests 307,
1013, 1022, 1275, 1707, 1708, 1710.


  • fix test 1275 silently skipping the test if git command is missing.
    Keep sliently skipping? or install git where missing? maybe make it not need git?

@vszakats
vszakats marked this pull request as draft March 25, 2026 18:06
```
test 1275...[Verify capital letters after period in markdown files]

/usr/bin/perl -I. -I/__w/curl/curl/tests  returned 2, when expecting 0
 1275: exit FAILED
== Contents of files in the log/3/ directory after test 1275
=== Start of file commands.log
 /usr/bin/perl -I. -I/__w/curl/curl/tests /__w/curl/curl/tests/test1275.pl /__w/curl/curl/tests/.. > log/3/stdout1275 2> log/3/stderr1275
=== End of file commands.log
=== Start of file server.cmd
 Testnum 1275
=== End of file server.cmd
=== Start of file stderr1275
 Can't exec "git": No such file or directory at /__w/curl/curl/tests/test1275.pl line 31.
 Died at /__w/curl/curl/tests/test1275.pl line 31.
 ```
 https://github.com/curl/curl/actions/runs/23556683852/job/68585280936?pr=21097
@testclutch

This comment was marked as resolved.

This reverts commit b95176b.

It works, but eats resources better used elsewhere. This test
is running the same regardless of platform and build settings,
and it's already running in most jobs. Installing git in the
few remaining ones is just waste.
@vszakats
vszakats marked this pull request as ready for review March 26, 2026 11:16
@vszakats
vszakats requested a review from Copilot March 26, 2026 11:16

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens several Perl scripts and test helpers by avoiding shell-interpreted command strings (backticks / open("|") / system("...")) and switching to list-form execution or Perl library calls, reducing injection risk and quoting pitfalls.

Changes:

  • Replace shell-based command invocations with open(..., '-|', ...) in multiple test scripts and tooling scripts.
  • Update test1707-related test definitions to match the new test1707.pl argument list (no intermediate output file).
  • Replace mv shell calls with File::Copy::move() in adddocsref.pl.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tests/test1707.pl Capture curl -h output via piped open() instead of shell redirection to a file.
tests/test1275.pl Replace backticks git ls-files with piped open() (but currently can still silently no-op if git is missing).
tests/libtest/test307.pl Use list-form piped open() for invoking curl to list engines.
tests/libtest/test1013.pl Use list-form piped open() for invoking curl-config via sh.
tests/libtest/test1022.pl Use list-form piped open() for invoking curl-config via sh.
tests/data/test1707 Update test command line for the new test1707.pl args.
tests/data/test1708 Update test command line for the new test1707.pl args.
tests/data/test1710 Update test command line for the new test1707.pl args.
scripts/singleuse.pl Harden git grep and nm invocations by using list-form piped open().
scripts/checksrc-all.pl Use list-form piped open() for git ls-files (but still contains a shell-based system() call).
docs/examples/adddocsref.pl Replace mv shell commands with File::Copy::move().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread scripts/checksrc-all.pl Resolved
Comment thread docs/examples/adddocsref.pl Resolved
Comment thread tests/test1707.pl Resolved
Comment thread tests/test1275.pl Resolved
Comment thread scripts/singleuse.pl Resolved
@vszakats vszakats closed this in 20914e3 Mar 26, 2026
@vszakats
vszakats deleted the perlsys branch March 26, 2026 13:20
outcast36 pushed a commit to greearb/curl that referenced this pull request Jun 3, 2026
In `adddocsref.pl`, `checksrc-all.pl`, `singleuse.pl` and tests 307, 1013,
1022, 1275, 1707, 1708, 1710.

Closes curl#21097
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants