Skip to content

Commit 9c5b29e

Browse files
committed
use yamerl instead
1 parent f813e4e commit 9c5b29e

File tree

10 files changed

+34
-74
lines changed

10 files changed

+34
-74
lines changed

gleam.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
name = "go_over"
22
version = "0.1.0"
3-
target = "javascript"
43
licences = ["MIT"]
54
repository = { type = "github", user = "bwireman", repo = "go-over" }
65
description = "Auditor for erlang and elixir dependencies in gleam projects"
@@ -23,6 +22,8 @@ simplifile = ">= 1.7.0 and < 2.0.0"
2322
filepath = ">= 1.0.0 and < 2.0.0"
2423
tom = ">= 1.0.0 and < 2.0.0"
2524
stoiridh_version = ">= 0.1.0 and < 1.0.0"
25+
yamerl = ">= 0.10.0 and < 1.0.0"
26+
gleam_erlang = ">= 0.25.0 and < 1.0.0"
2627

2728
[dev-dependencies]
2829
gleeunit = ">= 1.0.0 and < 2.0.0"

manifest.toml

+4
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,23 @@
33

44
packages = [
55
{ name = "filepath", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "filepath", source = "hex", outer_checksum = "EFB6FF65C98B2A16378ABC3EE2B14124168C0CE5201553DE652E2644DCFDB594" },
6+
{ name = "gleam_erlang", version = "0.25.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_erlang", source = "hex", outer_checksum = "054D571A7092D2A9727B3E5D183B7507DAB0DA41556EC9133606F09C15497373" },
67
{ name = "gleam_stdlib", version = "0.37.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "5398BD6C2ABA17338F676F42F404B9B7BABE1C8DC7380031ACB05BBE1BCF3742" },
78
{ name = "gleeunit", version = "1.1.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "72CDC3D3F719478F26C4E2C5FED3E657AC81EC14A47D2D2DEBB8693CA3220C3B" },
89
{ name = "shellout", version = "1.6.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "shellout", source = "hex", outer_checksum = "E2FCD18957F0E9F67E1F497FC9FF57393392F8A9BAEAEA4779541DE7A68DD7E0" },
910
{ name = "simplifile", version = "1.7.0", build_tools = ["gleam"], requirements = ["filepath", "gleam_stdlib"], otp_app = "simplifile", source = "hex", outer_checksum = "1D5DFA3A2F9319EC85825F6ED88B8E449F381B0D55A62F5E61424E748E7DDEB0" },
1011
{ name = "stoiridh_version", version = "0.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "stoiridh_version", source = "hex", outer_checksum = "298ABEA44DF37764A34C2E9190A84BF2770BC59DD9397C6DC7708040E5A0142B" },
1112
{ name = "tom", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "tom", source = "hex", outer_checksum = "A5364613E3DBF77F38EFF81DA9F99324086D029EC2B2D44348762FBE38602311" },
13+
{ name = "yamerl", version = "0.10.0", build_tools = ["rebar3"], requirements = [], otp_app = "yamerl", source = "hex", outer_checksum = "346ADB2963F1051DC837A2364E4ACF6EB7D80097C0F53CBDC3046EC8EC4B4E6E" },
1214
]
1315

1416
[requirements]
1517
filepath = { version = ">= 1.0.0 and < 2.0.0" }
18+
gleam_erlang = { version = ">= 0.25.0 and < 1.0.0"}
1619
gleam_stdlib = { version = ">= 0.34.0 and < 2.0.0" }
1720
gleeunit = { version = ">= 1.0.0 and < 2.0.0" }
1821
shellout = { version = ">= 1.6.0 and < 2.0.0" }
1922
simplifile = { version = ">= 1.7.0 and < 2.0.0" }
2023
stoiridh_version = { version = ">= 0.1.0 and < 1.0.0" }
2124
tom = { version = ">= 1.0.0 and < 2.0.0" }
25+
yamerl = { version = ">= 0.10.0 and < 1.0.0" }

package.json

-10
This file was deleted.

scripts/publish.sh

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ function publish {
2929
git push origin "$VER"
3030
echo "Publishing to Hex" "$VER"
3131
HEX_API_KEY=$(cat key._) gleam publish
32-
yarn publish
3332
echo "🚀"
3433
}
3534

scripts/update.sh

-7
This file was deleted.

src/go_over/advisories.gleam

+4-28
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,14 @@ import gleam/list
33
import gleam/option
44
import gleam/string
55
import go_over/comparisons
6+
import go_over/yaml
67
import shellout
78
import simplifile
89
import stoiridh/version.{type Version}
910
import tom
1011

11-
type YamlADV
12-
13-
@external(javascript, "./../yaml.mjs", "readADV")
14-
fn parse(path: String) -> YamlADV
15-
16-
@external(javascript, "./../yaml.mjs", "name")
17-
fn name(y: YamlADV) -> String
18-
19-
@external(javascript, "./../yaml.mjs", "first_patched_versions")
20-
fn first_patched_versions(y: YamlADV) -> List(String)
21-
22-
@external(javascript, "./../yaml.mjs", "vulnerable_version_ranges")
23-
fn vulnerable_version_ranges(y: YamlADV) -> List(String)
24-
2512
pub type ADV {
26-
ADV(
27-
name: String,
28-
first_patched_versions: List(String),
29-
vulnerable_version_ranges: List(String),
30-
file: String,
31-
)
13+
ADV(name: String, vulnerable_version_ranges: List(String), file: String)
3214
}
3315

3416
fn path() -> String {
@@ -61,14 +43,8 @@ fn read_manifest(path: String) {
6143
}
6244

6345
fn read_adv(path: String) {
64-
let assert Ok(contents) = simplifile.read(path)
65-
let parsed = parse(contents)
66-
ADV(
67-
name(parsed),
68-
first_patched_versions(parsed),
69-
vulnerable_version_ranges(parsed),
70-
path,
71-
)
46+
let #(name, vulnerable_version_ranges) = yaml.parse(path)
47+
ADV(name, vulnerable_version_ranges, path)
7248
}
7349

7450
fn read_all_adv() {

src/go_over/yaml.gleam

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import gleam/erlang
2+
import gleam/erlang/atom
3+
4+
pub fn start() {
5+
erlang.ensure_all_started(atom.create_from_string("yamerl"))
6+
}
7+
8+
@external(erlang, "yamll", "parse")
9+
pub fn parse(path: String) -> #(String, List(String))
10+
11+
12+

src/yaml.mjs

-19
This file was deleted.

src/yamll.erl

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
-module(yamll).
2+
3+
-export([
4+
parse/1
5+
]).
6+
7+
8+
parse(Path) ->
9+
[Content] = yamerl:decode_file(Path),
10+
Name = lists:keyfind("package", 1, Content),
11+
Vulnerable_version_ranges = lists:keyfind("vulnerable_version_ranges", 1, Content),
12+
{Name, Vulnerable_version_ranges}.

yarn.lock

-8
This file was deleted.

0 commit comments

Comments
 (0)