OSV.dev vulnerability database client
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

ocaml-osv: enable MDX on lib/osv.mli

Run mdx on lib/osv.mli so the {[ ... ]} odoc block now type-checks.

The example used `env#net` / `env#clock` directly (object-method
shorthand that requires being inside the right scope) and treated
`Osv.query_purl`'s `(_, string) result` return as a `vulnerability
list`. Wrapped in `let run () = Eio_main.run @@ ...`, switched to
`Eio.Stdenv.net` / `Eio.Stdenv.clock`, pattern-matched the result on
both branches with `Fmt.pr` / `Fmt.epr`, and annotated the iter
parameter as `(v : Osv.vulnerability)` so the field accesses resolve
unambiguously.

+18 -11
+4
lib/dune
··· 2 2 (name osv) 3 3 (public_name osv) 4 4 (libraries requests eio fmt logs astring nox-json)) 5 + 6 + (mdx 7 + (files osv.mli) 8 + (libraries osv fmt eio eio.core eio.unix eio_main))
+14 -11
lib/osv.mli
··· 14 14 {2 Quick Start} 15 15 16 16 {[ 17 - Eio_main.run @@ fun env -> 18 - Eio.Switch.run @@ fun sw -> 19 - let vulns = 20 - Osv.query_purl ~sw ~net:env#net ~clock:env#clock "pkg:npm/lodash@4.17.20" 21 - in 22 - List.iter 23 - (fun v -> 24 - Printf.printf "%s [%s]: %s\n" v.id 25 - (Osv.severity_to_string v.severity) 26 - v.summary) 27 - vulns 17 + let run () = 18 + Eio_main.run @@ fun env -> 19 + Eio.Switch.run @@ fun sw -> 20 + let net = Eio.Stdenv.net env in 21 + let clock = Eio.Stdenv.clock env in 22 + match Osv.query_purl ~sw ~net ~clock "pkg:npm/lodash@4.17.20" with 23 + | Error msg -> Fmt.epr "OSV query failed: %s@." msg 24 + | Ok vulns -> 25 + List.iter 26 + (fun (v : Osv.vulnerability) -> 27 + Fmt.pr "%s [%s]: %s@." v.id 28 + (Osv.severity_to_string v.severity) 29 + v.summary) 30 + vulns 28 31 ]} 29 32 30 33 {2 API Reference}