Skip to content
Permalink
Browse files Browse the repository at this point in the history
Merge pull request from GHSA-g86g-chm8-7r2p
File handling
  • Loading branch information
jsoref committed Jul 12, 2021
2 parents 6c4b24e + 2494e7c commit 436362f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
5 changes: 5 additions & 0 deletions common.sh
@@ -1,5 +1,10 @@
#!/bin/bash
if [ "$INITIALIZED" != defined ]; then
if [ "$RUNNER_OS" = "Windows" ]; then
echo "::error ::Windows isn't currently supported"
exit 5
fi

now() {
date +'%s%N'
}
Expand Down
4 changes: 2 additions & 2 deletions spelling-unknown-word-splitter.pl
Expand Up @@ -16,9 +16,9 @@

# skip files that don't exist (including dangling symlinks)
if (scalar @ARGV) {
@ARGV = grep {-r || $_ eq '-'} @ARGV;
@ARGV = grep {! -l && -f && -r} @ARGV;
unless (scalar @ARGV) {
print STDERR "None of the provided files are readable\n";
print STDERR "::warning ::Was not provided any regular readable files\n";
exit 0;
}
}
Expand Down
23 changes: 22 additions & 1 deletion unknown-words.sh
Expand Up @@ -373,7 +373,28 @@ check_dictionary() {
}

cleanup_file() {
maybe_bad="$1"
export maybe_bad="$1"

result=0
perl -e '
use Cwd qw(abs_path);
my $maybe_bad=abs_path($ENV{maybe_bad});
my $workspace_path=abs_path($ENV{GITHUB_WORKSPACE});
if ($maybe_bad !~ /^\Q$workspace_path\E/) {
print "::error ::Configuration files must live within $workspace_path...\n";
print "::error ::Unfortunately, file $maybe_bad appears to reside elsewhere.\n";
exit 3;
}
if ($maybe_bad =~ m{/\.git/}i) {
print "::error ::Configuration files must not live within `.git/`...\n";
print "::error ::Unfortunately, file $maybe_bad appears to.\n";
exit 4;
}
' || result=$?
if [ $result -gt 0 ]; then
quit $result
fi

type="$2"
case "$type" in
patterns|excludes|only)
Expand Down

0 comments on commit 436362f

Please sign in to comment.