| 53 | util_tests.check_results_against_expected(results, expected) |
| 54 | |
| 55 | def test_generate_purl(self): |
| 56 | package_advisory_urls = [ |
| 57 | "https://security.snyk.io/package/pip/jinja2", |
| 58 | "https://security.snyk.io/package/maven/org.apache.tomcat%3Atomcat", |
| 59 | "https://security.snyk.io/package/npm/semver-regex", |
| 60 | "https://security.snyk.io/package/npm/@urql%2Fnext", |
| 61 | "https://security.snyk.io/package/npm/@lobehub%2Fchat", |
| 62 | "https://security.snyk.io/package/npm/meshcentral", |
| 63 | "https://security.snyk.io/package/composer/bolt%2Fcore", |
| 64 | "https://security.snyk.io/package/linux/debain:11/trafficserver", |
| 65 | "https://security.snyk.io/package/linux/almalinux:8/rpm-plugin-fapolicyd", |
| 66 | "https://security.snyk.io/package/nuget/moment.js", |
| 67 | "https://security.snyk.io/package/cocoapods/ffmpeg", |
| 68 | "https://security.snyk.io/package/hex/coherence", |
| 69 | "https://security.snyk.io/package/rubygems/log4j-jars", |
| 70 | "https://security.snyk.io/package/golang/github.com%2Fgrafana%2Fgrafana%2Fpkg%2Fservices%2Fsqlstore%2Fmigrator", |
| 71 | "https://security.snyk.io/package/golang/github.com%2Fanswerdev%2Fanswer%2Finternal%2Frepo%2Factivity", |
| 72 | "https://security.snyk.io/package/golang/go.etcd.io%2Fetcd%2Fv3%2Fauth", |
| 73 | "https://security.snyk.io/package/golang/gopkg.in%2Fkubernetes%2Fkubernetes.v0%2Fpkg%2Fregistry%2Fpod", |
| 74 | "https://security.snyk.io/package/golang/gogs.io%2Fgogs%2Finternal%2Fdb", |
| 75 | "https://security.snyk.io/package/golang/golang.org%2Fx%2Fcrypto%2Fssh", |
| 76 | ] |
| 77 | |
| 78 | results = [ |
| 79 | PackageURL.to_string(snyk.generate_purl(package_advisory_url)) |
| 80 | for package_advisory_url in package_advisory_urls |
| 81 | ] |
| 82 | |
| 83 | expected = [ |
| 84 | "pkg:pypi/jinja2", |
| 85 | "pkg:maven/org.apache.tomcat/tomcat", |
| 86 | "pkg:npm/semver-regex", |
| 87 | "pkg:npm/%40urql/next", |
| 88 | "pkg:npm/%40lobehub/chat", |
| 89 | "pkg:npm/meshcentral", |
| 90 | "pkg:composer/bolt/core", |
| 91 | "pkg:linux/trafficserver", |
| 92 | "pkg:linux/rpm-plugin-fapolicyd", |
| 93 | "pkg:nuget/moment.js", |
| 94 | "pkg:cocoapods/ffmpeg", |
| 95 | "pkg:hex/coherence", |
| 96 | "pkg:gem/log4j-jars", |
| 97 | "pkg:golang/github.com/grafana/grafana/pkg/services/sqlstore/migrator", |
| 98 | "pkg:golang/github.com/answerdev/answer/internal/repo/activity", |
| 99 | "pkg:golang/go.etcd.io/etcd/v3/auth", |
| 100 | "pkg:golang/gopkg.in/kubernetes/kubernetes.v0/pkg/registry/pod", |
| 101 | "pkg:golang/gogs.io/gogs/internal/db", |
| 102 | "pkg:golang/golang.org/x/crypto/ssh", |
| 103 | ] |
| 104 | |
| 105 | util_tests.check_results_against_expected(results, expected) |
| 106 | |
| 107 | def test_parse_html_advisory_0(self): |
| 108 | file = self.get_test_loc("html/0.html") |