From b22e032281d186edcfb8feb27d3ec3299c9e99a9 Mon Sep 17 00:00:00 2001 From: al-obrien Date: Wed, 15 Nov 2023 10:09:42 -0700 Subject: [PATCH] pkg vulns test added --- .../api.osv.dev/v1/querybatch-8e4417-POST.json | 15 +++++++++++++++ .../api.osv.dev/v1/querybatch-97c633-POST.json | 15 +++++++++++++++ tests/testthat/test-query.R | 6 ++++++ 3 files changed, 36 insertions(+) create mode 100644 tests/testthat/is_pkg_vul/api.osv.dev/v1/querybatch-8e4417-POST.json create mode 100644 tests/testthat/is_pkg_vul/api.osv.dev/v1/querybatch-97c633-POST.json create mode 100644 tests/testthat/test-query.R diff --git a/tests/testthat/is_pkg_vul/api.osv.dev/v1/querybatch-8e4417-POST.json b/tests/testthat/is_pkg_vul/api.osv.dev/v1/querybatch-8e4417-POST.json new file mode 100644 index 0000000..336db10 --- /dev/null +++ b/tests/testthat/is_pkg_vul/api.osv.dev/v1/querybatch-8e4417-POST.json @@ -0,0 +1,15 @@ +{ + "results": [ + { + "vulns": [ + { + "id": "PYSEC-2021-387", + "modified": "2021-11-11T13:06:47.756280Z" + } + ] + }, + { + + } + ] +} diff --git a/tests/testthat/is_pkg_vul/api.osv.dev/v1/querybatch-97c633-POST.json b/tests/testthat/is_pkg_vul/api.osv.dev/v1/querybatch-97c633-POST.json new file mode 100644 index 0000000..d485ae3 --- /dev/null +++ b/tests/testthat/is_pkg_vul/api.osv.dev/v1/querybatch-97c633-POST.json @@ -0,0 +1,15 @@ +{ + "results": [ + { + "vulns": [ + { + "id": "RSEC-2023-2", + "modified": "2023-10-20T07:27:00.600Z" + } + ] + }, + { + + } + ] +} diff --git a/tests/testthat/test-query.R b/tests/testthat/test-query.R new file mode 100644 index 0000000..9c2730a --- /dev/null +++ b/tests/testthat/test-query.R @@ -0,0 +1,6 @@ +with_mock_dir('is_pkg_vul', { + test_that("Returns named vectors with correct logic", { + expect_equal(is_pkg_vulnerable(c('dask', 'data.table'), c('PyPI', 'CRAN')), c(dask = TRUE, data.table = FALSE)) + expect_equal(is_pkg_vulnerable(rep('readxl', 2), rep('CRAN', 2), version = c('1.4.1', '2.0.0')), c(readxl = TRUE, readxl = FALSE)) + }) +})