Skip to content

Commit 7219a1b

Browse files
committed
ensure subject globs match only files
Signed-off-by: Brian DeHamer <bdehamer@github.com>
1 parent 94082a9 commit 7219a1b

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

__tests__/subject.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,19 @@ describe('subjectFromInputs', () => {
203203
})
204204
})
205205

206+
describe('when a file glob is supplied which also matches non-files', () => {
207+
beforeEach(async () => {
208+
process.env['INPUT_SUBJECT-PATH'] = `${dir}*`
209+
})
210+
211+
it('returns the subjects (excluding non-files)', async () => {
212+
const subjects = await subjectFromInputs()
213+
214+
expect(subjects).toBeDefined()
215+
expect(subjects).toHaveLength(7)
216+
})
217+
})
218+
206219
describe('when a comma-separated list is supplied', () => {
207220
beforeEach(async () => {
208221
process.env['INPUT_SUBJECT-PATH'] =

src/subject.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ const getSubjectFromPath = async (
5656
const files = await glob.create(subPath).then(async g => g.glob())
5757

5858
for (const file of files) {
59+
// Skip anything that is NOT a file
60+
if (!fs.statSync(file).isFile()) {
61+
continue
62+
}
63+
5964
const name = subjectName || path.parse(file).base
6065
const digest = await digestFile(DIGEST_ALGORITHM, file)
6166

0 commit comments

Comments
 (0)