Repository: google/osv-scanner
Pull request #628 (2023-11-02 00:01:13)

test: check against error type rather than message
Cherry-picked from #553

---

It's required for testing against Windows because it has a different error message, but it's also just a good overall change and landing it separately removes ~25 files from the main PR 😅 

codecov-commenter: ## [Codecov](https://app.codecov.io/gh/google/osv-scanner/pull/628?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) Report
> Merging [#628](https://app.codecov.io/gh/google/osv-scanner/pull/628?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) (372613e) into [main](https://app.codecov.io/gh/google/osv-scanner/commit/ac2897cf3e69379831e4ca583d5a671c827369dd?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) (ac2897c) will **decrease** coverage by `1.52%`.
> Report is 1 commits behind head on main.
> The diff coverage is `2.80%`.

```diff
@@            Coverage Diff             @@
##             main     #628      +/-   ##
==========================================
- Coverage   80.33%   78.82%   -1.52%     
==========================================
  Files          78       78              
  Lines        5406     5511     +105     
==========================================
+ Hits         4343     4344       +1     
- Misses        887      990     +103     
- Partials      176      177       +1     
```


| [Files](https://app.codecov.io/gh/google/osv-scanner/pull/628?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) | Coverage Δ | |
|---|---|---|
| [pkg/osv/osv.go](https://app.codecov.io/gh/google/osv-scanner/pull/628?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google#diff-cGtnL29zdi9vc3YuZ28=) | `52.87% <0.00%> (-10.65%)` | :arrow_down: |
| [pkg/osvscanner/osvscanner.go](https://app.codecov.io/gh/google/osv-scanner/pull/628?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google#diff-cGtnL29zdnNjYW5uZXIvb3N2c2Nhbm5lci5nbw==) | `53.12% <4.00%> (-7.52%)` | :arrow_down: |



Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7742f0d..c8038bf 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,21 @@
+# v1.4.3:
+
+### Features
+- [Feature #621](https://github.com/google/osv-scanner/pull/621)
+  Add support for scanning vendored C/C++ files.
+- [Feature #581](https://github.com/google/osv-scanner/pull/581)
+  Scan submodules commit hashes.
+
+### Fixes
+- [Bug #626](https://github.com/google/osv-scanner/issues/626)
+  Fix gitignore matching for root directory
+- [Bug #622](https://github.com/google/osv-scanner/issues/622)
+  Go binary not found should not be an error
+- [Bug #588](https://github.com/google/osv-scanner/issues/588)
+  handle npm/yarn aliased packages
+- [Bug #607](https://github.com/google/osv-scanner/pull/607)
+  fix: remove some extra newlines in sarif report
+
 # v1.4.2:
 
 ### Fixes
diff --git a/docs/github-action.md b/docs/github-action.md
index 62bc7f0..7dee78e 100644
--- a/docs/github-action.md
+++ b/docs/github-action.md
@@ -150,7 +150,7 @@ name: OSV-Scanner Scheduled Scan
 
 on:
   schedule:
-    - cron: '12 12 * * 1'
+    - cron: '30 12 * * 1'
 # Change "main" to your default branch if you use a different name, i.e. "master"
   push:
     branches: [ main ]
@@ -166,7 +166,7 @@ jobs:
     uses: "google/osv-scanner/.github/workflows/osv-scanner-reusable.yml@main"
 ```
 
-As written, the scanner will run on 12:12 pm UTC every Monday. You can change the schedule by following the instructions [here](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule).
+As written, the scanner will run on 12:30 pm UTC every Monday, and also on every push to the main branch. You can change the schedule by following the instructions [here](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule).
 
 ### Customization
 
diff --git a/internal/version/version.go b/internal/version/version.go
index 6e1cb34..d45bb7f 100644
--- a/internal/version/version.go
+++ b/internal/version/version.go
@@ -1,4 +1,4 @@
 package version
 
 // OSVVersion is the current release version, you should update this variable when doing a release
-var OSVVersion = "1.4.2"
+var OSVVersion = "1.4.3"


Test patch:
diff --git a/internal/output/fixtures/test-vuln-results-a.sarif b/internal/output/fixtures/test-vuln-results-a.sarif
index 9878fb2..ad2cf97 100644
--- a/internal/output/fixtures/test-vuln-results-a.sarif
+++ b/internal/output/fixtures/test-vuln-results-a.sarif
@@ -49,7 +49,7 @@
               }
             }
           ],
-          "version": "1.4.2"
+          "version": "1.4.3"
         }
       },
       "artifacts": [
diff --git a/pkg/lockfile/apk-installed_test.go b/pkg/lockfile/apk-installed_test.go
index 7450e6b..5ddf9cb 100644
--- a/pkg/lockfile/apk-installed_test.go
+++ b/pkg/lockfile/apk-installed_test.go
@@ -1,6 +1,7 @@
 package lockfile_test
 
 import (
+	"io/fs"
 	"testing"
 
 	"github.com/google/osv-scanner/pkg/lockfile"
@@ -11,7 +12,7 @@ func TestParseApkInstalled_FileDoesNotExist(t *testing.T) {
 
 	packages, err := lockfile.ParseApkInstalled("fixtures/apk/does-not-exist")
 
-	expectErrContaining(t, err, "no such file or directory")
+	expectErrIs(t, err, fs.ErrNotExist)
 	expectPackages(t, packages, []lockfile.PackageDetails{})
 }
 
diff --git a/pkg/lockfile/dpkg-status_test.go b/pkg/lockfile/dpkg-status_test.go
index 69711f3..128af88 100644
--- a/pkg/lockfile/dpkg-status_test.go
+++ b/pkg/lockfile/dpkg-status_test.go
@@ -1,6 +1,7 @@
 package lockfile_test
 
 import (
+	"io/fs"
 	"testing"
 
 	"github.com/google/osv-scanner/pkg/lockfile"
@@ -11,7 +12,7 @@ func TestParseDpkgStatus_FileDoesNotExist(t *testing.T) {
 
 	packages, err := lockfile.ParseDpkgStatus("fixtures/dpkg/does-not-exist")
 
-	expectErrContaining(t, err, "no such file or directory")
+	expectErrIs(t, err, fs.ErrNotExist)
 	expectPackages(t, packages, []lockfile.PackageDetails{})
 }
 
diff --git a/pkg/lockfile/helpers_test.go b/pkg/lockfile/helpers_test.go
index c32f9f8..90c7158 100644
--- a/pkg/lockfile/helpers_test.go
+++ b/pkg/lockfile/helpers_test.go
@@ -1,6 +1,7 @@
 package lockfile_test
 
 import (
+	"errors"
 	"fmt"
 	"strings"
 	"testing"
@@ -21,6 +22,18 @@ func expectErrContaining(t *testing.T, err error, str string) {
 	}
 }
 
+func expectErrIs(t *testing.T, err error, expected error) {
+	t.Helper()
+
+	if err == nil {
+		t.Errorf("Expected to get error, but did not")
+	}
+
+	if !errors.Is(err, expected) {
+		t.Errorf("Expected to get \"%v\" error but got \"%v\" instead", expected, err)
+	}
+}
+
 func packageToString(pkg lockfile.PackageDetails) string {
 	commit := pkg.Commit
 
diff --git a/pkg/lockfile/osv-vuln-result_test.go b/pkg/lockfile/osv-vuln-result_test.go
index 773e6e9..be69443 100644
--- a/pkg/lockfile/osv-vuln-result_test.go
+++ b/pkg/lockfile/osv-vuln-result_test.go
@@ -1,6 +1,7 @@
 package lockfile_test
 
 import (
+	"io/fs"
 	"testing"
 
 	"github.com/google/osv-scanner/pkg/lockfile"
@@ -11,7 +12,7 @@ func TestParseOSVScannerResults_FileDoesNotExist(t *testing.T) {
 
 	packages, err := lockfile.ParseOSVScannerResults("fixtures/osvscannerresults/does-not-exist")
 
-	expectErrContaining(t, err, "no such file or directory")
+	expectErrIs(t, err, fs.ErrNotExist)
 	expectPackages(t, packages, []lockfile.PackageDetails{})
 }
 
diff --git a/pkg/lockfile/parse-cargo-lock_test.go b/pkg/lockfile/parse-cargo-lock_test.go
index 1f104e3..61baa06 100644
--- a/pkg/lockfile/parse-cargo-lock_test.go
+++ b/pkg/lockfile/parse-cargo-lock_test.go
@@ -1,6 +1,7 @@
 package lockfile_test
 
 import (
+	"io/fs"
 	"testing"
 
 	"github.com/google/osv-scanner/pkg/lockfile"
@@ -63,7 +64,7 @@ func TestParseCargoLock_FileDoesNotExist(t *testing.T) {
 
 	packages, err := lockfile.ParseCargoLock("fixtures/cargo/does-not-exist")
 
-	expectErrContaining(t, err, "no such file or directory")
+	expectErrIs(t, err, fs.ErrNotExist)
 	expectPackages(t, packages, []lockfile.PackageDetails{})
 }
 
diff --git a/pkg/lockfile/parse-composer-lock_test.go b/pkg/lockfile/parse-composer-lock_test.go
index 69f3cb6..befaf54 100644
--- a/pkg/lockfile/parse-composer-lock_test.go
+++ b/pkg/lockfile/parse-composer-lock_test.go
@@ -1,6 +1,7 @@
 package lockfile_test
 
 import (
+	"io/fs"
 	"testing"
 
 	"github.com/google/osv-scanner/pkg/lockfile"
@@ -63,7 +64,7 @@ func TestParseComposerLock_FileDoesNotExist(t *testing.T) {
 
 	packages, err := lockfile.ParseComposerLock("fixtures/composer/does-not-exist")
 
-	expectErrContaining(t, err, "no such file or directory")
+	expectErrIs(t, err, fs.ErrNotExist)
 	expectPackages(t, packages, []lockfile.PackageDetails{})
 }
 
diff --git a/pkg/lockfile/parse-conan-lock-v1-revisions_test.go b/pkg/lockfile/parse-conan-lock-v1-revisions_test.go
index d64b444..e20101a 100644
--- a/pkg/lockfile/parse-conan-lock-v1-revisions_test.go
+++ b/pkg/lockfile/parse-conan-lock-v1-revisions_test.go
@@ -1,6 +1,7 @@
 package lockfile_test
 
 import (
+	"io/fs"
 	"testing"
 
 	"github.com/google/osv-scanner/pkg/lockfile"
@@ -11,7 +12,7 @@ func TestParseConanLock_v1_revisions_FileDoesNotExist(t *testing.T) {
 
 	packages, err := lockfile.ParseConanLock("fixtures/conan/does-not-exist")
 
-	expectErrContaining(t, err, "no such file or directory")
+	expectErrIs(t, err, fs.ErrNotExist)
 	expectPackages(t, packages, []lockfile.PackageDetails{})
 }
 
diff --git a/pkg/lockfile/parse-conan-lock-v1_test.go b/pkg/lockfile/parse-conan-lock-v1_test.go
index bea8bfb..390232a 100644
--- a/pkg/lockfile/parse-conan-lock-v1_test.go
+++ b/pkg/lockfile/parse-conan-lock-v1_test.go
@@ -1,6 +1,7 @@
 package lockfile_test
 
 import (
+	"io/fs"
 	"testing"
 
 	"github.com/google/osv-scanner/pkg/lockfile"
@@ -11,7 +12,7 @@ func TestParseConanLock_v1_FileDoesNotExist(t *testing.T) {
 
 	packages, err := lockfile.ParseConanLock("fixtures/conan/does-not-exist")
 
-	expectErrContaining(t, err, "no such file or directory")
+	expectErrIs(t, err, fs.ErrNotExist)
 	expectPackages(t, packages, []lockfile.PackageDetails{})
 }
 
diff --git a/pkg/lockfile/parse-conan-lock-v2_test.go b/pkg/lockfile/parse-conan-lock-v2_test.go
index 0bf13e4..8e2a8da 100644
--- a/pkg/lockfile/parse-conan-lock-v2_test.go
+++ b/pkg/lockfile/parse-conan-lock-v2_test.go
@@ -1,6 +1,7 @@
 package lockfile_test
 
 import (
+	"io/fs"
 	"testing"
 
 	"github.com/google/osv-scanner/pkg/lockfile"
@@ -11,7 +12,7 @@ func TestParseConanLock_v2_FileDoesNotExist(t *testing.T) {
 
 	packages, err := lockfile.ParseConanLock("fixtures/conan/does-not-exist")
 
-	expectErrContaining(t, err, "no such file or directory")
+	expectErrIs(t, err, fs.ErrNotExist)
 	expectPackages(t, packages, []lockfile.PackageDetails{})
 }
 
diff --git a/pkg/lockfile/parse-gemfile-lock_test.go b/pkg/lockfile/parse-gemfile-lock_test.go
index 14bc2c9..cb9a20e 100644
--- a/pkg/lockfile/parse-gemfile-lock_test.go
+++ b/pkg/lockfile/parse-gemfile-lock_test.go
@@ -1,6 +1,7 @@
 package lockfile_test
 
 import (
+	"io/fs"
 	"testing"
 
 	"github.com/google/osv-scanner/pkg/lockfile"
@@ -63,7 +64,7 @@ func TestParseGemfileLock_FileDoesNotExist(t *testing.T) {
 
 	packages, err := lockfile.ParseGemfileLock("fixtures/bundler/does-not-exist")
 
-	expectErrContaining(t, err, "no such file or directory")
+	expectErrIs(t, err, fs.ErrNotExist)
 	expectPackages(t, packages, []lockfile.PackageDetails{})
 }
 
diff --git a/pkg/lockfile/parse-go-lock_test.go b/pkg/lockfile/parse-go-lock_test.go
index bc90029..f1de2ae 100644
--- a/pkg/lockfile/parse-go-lock_test.go
+++ b/pkg/lockfile/parse-go-lock_test.go
@@ -1,6 +1,7 @@
 package lockfile_test
 
 import (
+	"io/fs"
 	"testing"
 
 	"github.com/google/osv-scanner/pkg/lockfile"
@@ -63,7 +64,7 @@ func TestParseGoLock_FileDoesNotExist(t *testing.T) {
 
 	packages, err := lockfile.ParseGoLock("fixtures/go/does-not-exist")
 
-	expectErrContaining(t, err, "no such file or directory")
+	expectErrIs(t, err, fs.ErrNotExist)
 	expectPackages(t, packages, []lockfile.PackageDetails{})
 }
 
diff --git a/pkg/lockfile/parse-gradle-lock_test.go b/pkg/lockfile/parse-gradle-lock_test.go
index 2da55ec..f0bea68 100644
--- a/pkg/lockfile/parse-gradle-lock_test.go
+++ b/pkg/lockfile/parse-gradle-lock_test.go
@@ -1,6 +1,7 @@
 package lockfile_test
 
 import (
+	"io/fs"
 	"testing"
 
 	"github.com/google/osv-scanner/pkg/lockfile"
@@ -88,7 +89,7 @@ func TestParseGradleLock_FileDoesNotExist(t *testing.T) {
 
 	packages, err := lockfile.ParseGradleLock("fixtures/gradle/does-not-exist")
 
-	expectErrContaining(t, err, "no such file or directory")
+	expectErrIs(t, err, fs.ErrNotExist)
 	expectPackages(t, packages, []lockfile.PackageDetails{})
 }
 
diff --git a/pkg/lockfile/parse-maven-lock_test.go b/pkg/lockfile/parse-maven-lock_test.go
index a974f97..38b2edd 100644
--- a/pkg/lockfile/parse-maven-lock_test.go
+++ b/pkg/lockfile/parse-maven-lock_test.go
@@ -1,6 +1,7 @@
 package lockfile_test
 
 import (
+	"io/fs"
 	"testing"
 
 	"github.com/google/osv-scanner/pkg/lockfile"
@@ -63,7 +64,7 @@ func TestParseMavenLock_FileDoesNotExist(t *testing.T) {
 
 	packages, err := lockfile.ParseMavenLock("fixtures/maven/does-not-exist")
 
-	expectErrContaining(t, err, "no such file or directory")
+	expectErrIs(t, err, fs.ErrNotExist)
 	expectPackages(t, packages, []lockfile.PackageDetails{})
 }
 
diff --git a/pkg/lockfile/parse-mix-lock_test.go b/pkg/lockfile/parse-mix-lock_test.go
index 1bf0c94..6de2af8 100644
--- a/pkg/lockfile/parse-mix-lock_test.go
+++ b/pkg/lockfile/parse-mix-lock_test.go
@@ -1,6 +1,7 @@
 package lockfile_test
 
 import (
+	"io/fs"
 	"testing"
 
 	"github.com/google/osv-scanner/pkg/lockfile"
@@ -63,7 +64,7 @@ func TestParseMixLock_FileDoesNotExist(t *testing.T) {
 
 	packages, err := lockfile.ParseMixLock("fixtures/mix/does-not-exist")
 
-	expectErrContaining(t, err, "no such file or directory")
+	expectErrIs(t, err, fs.ErrNotExist)
 	expectPackages(t, packages, []lockfile.PackageDetails{})
 }
 
diff --git a/pkg/lockfile/parse-npm-lock-v1_test.go b/pkg/lockfile/parse-npm-lock-v1_test.go
index 154d79d..fa129a8 100644
--- a/pkg/lockfile/parse-npm-lock-v1_test.go
+++ b/pkg/lockfile/parse-npm-lock-v1_test.go
@@ -1,6 +1,7 @@
 package lockfile_test
 
 import (
+	"io/fs"
 	"testing"
 
 	"github.com/google/osv-scanner/pkg/lockfile"
@@ -11,7 +12,7 @@ func TestParseNpmLock_v1_FileDoesNotExist(t *testing.T) {
 
 	packages, err := lockfile.ParseNpmLock("fixtures/npm/does-not-exist")
 
-	expectErrContaining(t, err, "no such file or directory")
+	expectErrIs(t, err, fs.ErrNotExist)
 	expectPackages(t, packages, []lockfile.PackageDetails{})
 }
 
diff --git a/pkg/lockfile/parse-npm-lock-v2_test.go b/pkg/lockfile/parse-npm-lock-v2_test.go
index 2b0cfb7..33b7a63 100644
--- a/pkg/lockfile/parse-npm-lock-v2_test.go
+++ b/pkg/lockfile/parse-npm-lock-v2_test.go
@@ -1,6 +1,7 @@
 package lockfile_test
 
 import (
+	"io/fs"
 	"testing"
 
 	"github.com/google/osv-scanner/pkg/lockfile"
@@ -11,7 +12,7 @@ func TestParseNpmLock_v2_FileDoesNotExist(t *testing.T) {
 
 	packages, err := lockfile.ParseNpmLock("fixtures/npm/does-not-exist")
 
-	expectErrContaining(t, err, "no such file or directory")
+	expectErrIs(t, err, fs.ErrNotExist)
 	expectPackages(t, packages, []lockfile.PackageDetails{})
 }
 
diff --git a/pkg/lockfile/parse-nuget-lock-v1_test.go b/pkg/lockfile/parse-nuget-lock-v1_test.go
index b5619d9..0397720 100644
--- a/pkg/lockfile/parse-nuget-lock-v1_test.go
+++ b/pkg/lockfile/parse-nuget-lock-v1_test.go
@@ -1,6 +1,7 @@
 package lockfile_test
 
 import (
+	"io/fs"
 	"testing"
 
 	"github.com/google/osv-scanner/pkg/lockfile"
@@ -11,7 +12,7 @@ func TestParseNuGetLock_v1_FileDoesNotExist(t *testing.T) {
 
 	packages, err := lockfile.ParseNuGetLock("fixtures/nuget/does-not-exist")
 
-	expectErrContaining(t, err, "no such file or directory")
+	expectErrIs(t, err, fs.ErrNotExist)
 	expectPackages(t, packages, []lockfile.PackageDetails{})
 }
 
diff --git a/pkg/lockfile/parse-pipenv-lock_test.go b/pkg/lockfile/parse-pipenv-lock_test.go
index d48e5a0..df672d7 100644
--- a/pkg/lockfile/parse-pipenv-lock_test.go
+++ b/pkg/lockfile/parse-pipenv-lock_test.go
@@ -1,6 +1,7 @@
 package lockfile_test
 
 import (
+	"io/fs"
 	"testing"
 
 	"github.com/google/osv-scanner/pkg/lockfile"
@@ -63,7 +64,7 @@ func TestParsePipenvLock_FileDoesNotExist(t *testing.T) {
 
 	packages, err := lockfile.ParsePipenvLock("fixtures/pipenv/does-not-exist")
 
-	expectErrContaining(t, err, "no such file or directory")
+	expectErrIs(t, err, fs.ErrNotExist)
 	expectPackages(t, packages, []lockfile.PackageDetails{})
 }
 
diff --git a/pkg/lockfile/parse-pnpm-lock_test.go b/pkg/lockfile/parse-pnpm-lock_test.go
index 306c926..bf6aecc 100644
--- a/pkg/lockfile/parse-pnpm-lock_test.go
+++ b/pkg/lockfile/parse-pnpm-lock_test.go
@@ -1,6 +1,7 @@
 package lockfile_test
 
 import (
+	"io/fs"
 	"testing"
 
 	"github.com/google/osv-scanner/pkg/lockfile"
@@ -63,7 +64,7 @@ func TestParsePnpmLock_FileDoesNotExist(t *testing.T) {
 
 	packages, err := lockfile.ParsePnpmLock("fixtures/pnpm/does-not-exist")
 
-	expectErrContaining(t, err, "no such file or directory")
+	expectErrIs(t, err, fs.ErrNotExist)
 	expectPackages(t, packages, []lockfile.PackageDetails{})
 }
 
diff --git a/pkg/lockfile/parse-poetry-lock_test.go b/pkg/lockfile/parse-poetry-lock_test.go
index d5afcf6..4a146b9 100644
--- a/pkg/lockfile/parse-poetry-lock_test.go
+++ b/pkg/lockfile/parse-poetry-lock_test.go
@@ -1,6 +1,7 @@
 package lockfile_test
 
 import (
+	"io/fs"
 	"testing"
 
 	"github.com/google/osv-scanner/pkg/lockfile"
@@ -63,7 +64,7 @@ func TestParsePoetryLock_FileDoesNotExist(t *testing.T) {
 
 	packages, err := lockfile.ParsePoetryLock("fixtures/poetry/does-not-exist")
 
-	expectErrContaining(t, err, "no such file or directory")
+	expectErrIs(t, err, fs.ErrNotExist)
 	expectPackages(t, packages, []lockfile.PackageDetails{})
 }
 
diff --git a/pkg/lockfile/parse-pubspec-lock_test.go b/pkg/lockfile/parse-pubspec-lock_test.go
index 7423ce3..c08e535 100644
--- a/pkg/lockfile/parse-pubspec-lock_test.go
+++ b/pkg/lockfile/parse-pubspec-lock_test.go
@@ -1,6 +1,7 @@
 package lockfile_test
 
 import (
+	"io/fs"
 	"testing"
 
 	"github.com/google/osv-scanner/pkg/lockfile"
@@ -63,7 +64,7 @@ func TestParsePubspecLock_FileDoesNotExist(t *testing.T) {
 
 	packages, err := lockfile.ParsePubspecLock("fixtures/pub/does-not-exist")
 
-	expectErrContaining(t, err, "no such file or directory")
+	expectErrIs(t, err, fs.ErrNotExist)
 	expectPackages(t, packages, []lockfile.PackageDetails{})
 }
 
diff --git a/pkg/lockfile/parse-requirements-txt_test.go b/pkg/lockfile/parse-requirements-txt_test.go
index c6918e2..2d201bb 100644
--- a/pkg/lockfile/parse-requirements-txt_test.go
+++ b/pkg/lockfile/parse-requirements-txt_test.go
@@ -1,6 +1,7 @@
 package lockfile_test
 
 import (
+	"io/fs"
 	"testing"
 
 	"github.com/google/osv-scanner/pkg/lockfile"
@@ -63,7 +64,7 @@ func TestParseRequirementsTxt_FileDoesNotExist(t *testing.T) {
 
 	packages, err := lockfile.ParseRequirementsTxt("fixtures/pip/does-not-exist")
 
-	expectErrContaining(t, err, "no such file or directory")
+	expectErrIs(t, err, fs.ErrNotExist)
 	expectPackages(t, packages, []lockfile.PackageDetails{})
 }
 
@@ -482,7 +483,7 @@ func TestParseRequirementsTxt_WithBadROption(t *testing.T) {
 
 	packages, err := lockfile.ParseRequirementsTxt("fixtures/pip/with-bad-r-option.txt")
 
-	expectErrContaining(t, err, "no such file or directory")
+	expectErrIs(t, err, fs.ErrNotExist)
 	expectPackages(t, packages, []lockfile.PackageDetails{})
 }
 
diff --git a/pkg/lockfile/parse-yarn-lock-v1_test.go b/pkg/lockfile/parse-yarn-lock-v1_test.go
index c5d1ba5..459672f 100644
--- a/pkg/lockfile/parse-yarn-lock-v1_test.go
+++ b/pkg/lockfile/parse-yarn-lock-v1_test.go
@@ -1,6 +1,7 @@
 package lockfile_test
 
 import (
+	"io/fs"
 	"testing"
 
 	"github.com/google/osv-scanner/pkg/lockfile"
@@ -11,7 +12,7 @@ func TestParseYarnLock_v1_FileDoesNotExist(t *testing.T) {
 
 	packages, err := lockfile.ParseYarnLock("fixtures/yarn/does-not-exist")
 
-	expectErrContaining(t, err, "no such file or directory")
+	expectErrIs(t, err, fs.ErrNotExist)
 	expectPackages(t, packages, []lockfile.PackageDetails{})
 }
 
diff --git a/pkg/lockfile/parse-yarn-lock-v2_test.go b/pkg/lockfile/parse-yarn-lock-v2_test.go
index ba1bcc3..64cde52 100644
--- a/pkg/lockfile/parse-yarn-lock-v2_test.go
+++ b/pkg/lockfile/parse-yarn-lock-v2_test.go
@@ -1,6 +1,7 @@
 package lockfile_test
 
 import (
+	"io/fs"
 	"testing"
 
 	"github.com/google/osv-scanner/pkg/lockfile"
@@ -11,7 +12,7 @@ func TestParseYarnLock_v2_FileDoesNotExist(t *testing.T) {
 
 	packages, err := lockfile.ParseYarnLock("fixtures/yarn/does-not-exist")
 
-	expectErrContaining(t, err, "no such file or directory")
+	expectErrIs(t, err, fs.ErrNotExist)
 	expectPackages(t, packages, []lockfile.PackageDetails{})
 }
 
diff --git a/pkg/lockfile/parse_test.go b/pkg/lockfile/parse_test.go
index 8d5ecae..aaef2c1 100644
--- a/pkg/lockfile/parse_test.go
+++ b/pkg/lockfile/parse_test.go
@@ -134,13 +134,7 @@ func TestParse_ParserNotFound(t *testing.T) {
 
 	_, err := lockfile.Parse("/path/to/my/", "")
 
-	if err == nil {
-		t.Errorf("Expected to get an error but did not")
-	}
-
-	if !errors.Is(err, lockfile.ErrParserNotFound) {
-		t.Errorf("Did not get the expected ErrParserNotFound error - got %v instead", err)
-	}
+	expectErrIs(t, err, lockfile.ErrParserNotFound)
 }
 
 func TestParse_ParserNotFound_WithExplicitParseAs(t *testing.T) {