Skip to content

Commit 436362f

Browse files
authored
Merge pull request from GHSA-g86g-chm8-7r2p
File handling
2 parents 6c4b24e + 2494e7c commit 436362f

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed

Diff for: common.sh

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
#!/bin/bash
22
if [ "$INITIALIZED" != defined ]; then
3+
if [ "$RUNNER_OS" = "Windows" ]; then
4+
echo "::error ::Windows isn't currently supported"
5+
exit 5
6+
fi
7+
38
now() {
49
date +'%s%N'
510
}

Diff for: spelling-unknown-word-splitter.pl

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616

1717
# skip files that don't exist (including dangling symlinks)
1818
if (scalar @ARGV) {
19-
@ARGV = grep {-r || $_ eq '-'} @ARGV;
19+
@ARGV = grep {! -l && -f && -r} @ARGV;
2020
unless (scalar @ARGV) {
21-
print STDERR "None of the provided files are readable\n";
21+
print STDERR "::warning ::Was not provided any regular readable files\n";
2222
exit 0;
2323
}
2424
}

Diff for: unknown-words.sh

+22-1
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,28 @@ check_dictionary() {
373373
}
374374

375375
cleanup_file() {
376-
maybe_bad="$1"
376+
export maybe_bad="$1"
377+
378+
result=0
379+
perl -e '
380+
use Cwd qw(abs_path);
381+
my $maybe_bad=abs_path($ENV{maybe_bad});
382+
my $workspace_path=abs_path($ENV{GITHUB_WORKSPACE});
383+
if ($maybe_bad !~ /^\Q$workspace_path\E/) {
384+
print "::error ::Configuration files must live within $workspace_path...\n";
385+
print "::error ::Unfortunately, file $maybe_bad appears to reside elsewhere.\n";
386+
exit 3;
387+
}
388+
if ($maybe_bad =~ m{/\.git/}i) {
389+
print "::error ::Configuration files must not live within `.git/`...\n";
390+
print "::error ::Unfortunately, file $maybe_bad appears to.\n";
391+
exit 4;
392+
}
393+
' || result=$?
394+
if [ $result -gt 0 ]; then
395+
quit $result
396+
fi
397+
377398
type="$2"
378399
case "$type" in
379400
patterns|excludes|only)

0 commit comments

Comments
 (0)