deduplicate subjects before adding to statement (#180)

Signed-off-by: Brian DeHamer <bdehamer@github.com>
This commit is contained in:
Brian DeHamer
2024-12-06 07:14:14 -08:00
committed by GitHub
parent 4cd38b497a
commit 65e34a8aa7
5 changed files with 40 additions and 5 deletions
+8 -1
View File
@@ -84,7 +84,14 @@ const getSubjectFromPath = async (
const name = subjectName || path.parse(file).base
const digest = await digestFile(DIGEST_ALGORITHM, file)
digestedSubjects.push({ name, digest: { [DIGEST_ALGORITHM]: digest } })
// Only add the subject if it is not already in the list
if (
!digestedSubjects.some(
s => s.name === name && s.digest[DIGEST_ALGORITHM] === digest
)
) {
digestedSubjects.push({ name, digest: { [DIGEST_ALGORITHM]: digest } })
}
}
if (digestedSubjects.length === 0) {