Skip to content

[BUG] Integrity#match doesn't always find common algorithm #41

@pasieronen

Description

@pasieronen

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

An input containing both sha1+sha512 matches an input with only sha1, but not vice versa:

const ssri = require('ssri')

const sha1 = 'sha1-X1UT+IIv2+UUWvM7ZNjZcNz5XG4='
const sha512 = 'sha512-yzd8ELD1piyANiWnmdnpCL5F52f10UfUdEkHywVZeqTt0ymgrxR63Qz0GB7TKPoeeZQmWCaz7T1+9vBnypkYWg=='
const both = sha1 + ' ' + sha512

// returns truthy
console.log('both,sha1=', ssri.parse(both).match(sha1))
// returns false
console.log('sha1,both=', ssri.parse(sha1).match(both))

Expected Behavior

I would have expected both calls to return a truthy value, since they have an algorithm in common, and the hash matches.

Steps To Reproduce

No response

Environment

  • ssri: 9.0.1
  • Node: 16.15.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingNeeds Triageneeds an initial review

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions