Skip to content

Commit

Permalink
feat: add support to ada and simdutf
Browse files Browse the repository at this point in the history
  • Loading branch information
RafaelGSS committed Oct 23, 2023
1 parent 2e2d73f commit 46323b1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
11 changes: 11 additions & 0 deletions dep_checker/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def get_cpe(self, repo_path: Path) -> Optional[str]:
]

common_dependencies: list[str] = [
"ada",
"acorn",
"brotli",
"c-ares",
Expand All @@ -50,7 +51,9 @@ def get_cpe(self, repo_path: Path) -> Optional[str]:
"npm",
"OpenSSL",
"libuv",
"simdutf",
"uvwasi",
"undici",
"zlib",
]

Expand All @@ -64,6 +67,14 @@ def get_cpe(self, repo_path: Path) -> Optional[str]:


dependencies_info: dict[str, Dependency] = {
"ada": Dependency(
version_parser=vp.get_ada_version,
cpe=CPE(vendor="ada-url", product="ada"),
),
"simdutf": Dependency(
version_parser=vp.get_simdutf_version,
cpe=CPE(vendor="simdutf", product="simdutf"),
),
"zlib": Dependency(
version_parser=vp.get_zlib_version,
cpe=CPE(vendor="zlib", product="zlib"),
Expand Down
14 changes: 14 additions & 0 deletions dep_checker/versions_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,3 +204,17 @@ def get_zlib_version(repo_path: Path) -> str:
if matches is None:
raise RuntimeError("Error extracting version number for zlib")
return matches.groupdict()["version"]

def get_simdutf_version(repo_path: Path) -> str:
with open(repo_path / "deps/simdutf/simdutf.h", "r") as f:
matches = re.search('#define SIMDUTF_VERSION "(?P<version>.*)"', f.read())
if matches is None:
raise RuntimeError("Error extracting version number for simdutf")
return matches.groupdict()["version"]

def get_ada_version(repo_path: Path) -> str:
with open(repo_path / "deps/ada/ada.h", "r") as f:
matches = re.search('#define ADA_VERSION "(?P<version>.*)"', f.read())
if matches is None:
raise RuntimeError("Error extracting version number for ada")
return matches.groupdict()["version"]

0 comments on commit 46323b1

Please sign in to comment.