diff --git a/Gopkg.lock b/Gopkg.lock
index 228f021..8467342 100644
--- a/Gopkg.lock
+++ b/Gopkg.lock
@@ -2,6 +2,7 @@
[[projects]]
+ digest = "1:8bdd161127646f035e63906b6fd7be11a25a16194f92b59214927f1b418f6c22"
name = "github.com/coreos/etcd"
packages = [
"auth/authpb",
@@ -10,121 +11,151 @@
"etcdserver/api/v3rpc/rpctypes",
"etcdserver/etcdserverpb",
"mvcc/mvccpb",
- "pkg/types"
+ "pkg/types",
]
+ pruneopts = "UT"
revision = "2cf9e51d2a78003b164c2998886158e60ded1cbb"
version = "v3.3.11"
[[projects]]
+ digest = "1:ffe9824d294da03b391f44e1ae8281281b4afc1bdaa9588c9097785e3af10cec"
name = "github.com/davecgh/go-spew"
packages = ["spew"]
+ pruneopts = "UT"
revision = "8991bc29aa16c548c550c7ff78260e27b9ab7c73"
version = "v1.1.1"
[[projects]]
+ digest = "1:a9c85389dbd301c97a3499fe15a2b65b505b5f0cb0f1120dea59f1f3d6b11d96"
name = "github.com/gogo/protobuf"
packages = [
"gogoproto",
"proto",
- "protoc-gen-gogo/descriptor"
+ "protoc-gen-gogo/descriptor",
]
+ pruneopts = "UT"
revision = "4cbf7e384e768b4e01799441fdf2a706a5635ae7"
version = "v1.2.0"
[[projects]]
+ digest = "1:4c0989ca0bcd10799064318923b9bc2db6b4d6338dd75f3f2d86c3511aaaf5cf"
name = "github.com/golang/protobuf"
packages = [
"proto",
"ptypes",
"ptypes/any",
"ptypes/duration",
- "ptypes/timestamp"
+ "ptypes/timestamp",
]
+ pruneopts = "UT"
revision = "aa810b61a9c79d51363740d207bb46cf8e620ed5"
version = "v1.2.0"
[[projects]]
+ digest = "1:2b7795576f6f15c68487b332fcdd723ef52df627fa34a57d62255d6d1349482d"
name = "github.com/heetch/confita"
packages = [
".",
"backend",
"backend/env",
- "backend/flags"
+ "backend/flags",
]
+ pruneopts = "UT"
revision = "67096f89cfbe7bfed88e320a8bf4399f50a29667"
version = "v0.5.1"
[[projects]]
+ digest = "1:0981502f9816113c9c8c4ac301583841855c8cf4da8c72f696b3ebedf6d0e4e5"
name = "github.com/mattn/go-isatty"
packages = ["."]
+ pruneopts = "UT"
revision = "6ca4dbf54d38eea1a992b3c722a76a5d1c4cb25c"
version = "v0.0.4"
[[projects]]
+ digest = "1:cf31692c14422fa27c83a05292eb5cbe0fb2775972e8f1f8446a71549bd8980b"
name = "github.com/pkg/errors"
packages = ["."]
+ pruneopts = "UT"
revision = "ba968bfe8b2f7e042a574c888954fccecfa385b4"
version = "v0.8.1"
[[projects]]
+ digest = "1:0028cb19b2e4c3112225cd871870f2d9cf49b9b4276531f03438a88e94be86fe"
name = "github.com/pmezard/go-difflib"
packages = ["difflib"]
+ pruneopts = "UT"
revision = "792786c7400a136282c1664665ae0a8db921c6c2"
version = "v1.0.0"
[[projects]]
+ digest = "1:2e76a73cb51f42d63a2a1a85b3dc5731fd4faf6821b434bd0ef2c099186031d6"
name = "github.com/rs/xid"
packages = ["."]
+ pruneopts = "UT"
revision = "15d26544def341f036c5f8dca987a4cbe575032c"
version = "v1.2.1"
[[projects]]
+ digest = "1:e8b399407b20da4125acce061053fd230013ec65cd07fa90ba72bba57cd85232"
name = "github.com/rs/zerolog"
packages = [
".",
"hlog",
"internal/cbor",
"internal/json",
- "log"
+ "log",
]
+ pruneopts = "UT"
revision = "8747b7b3a51b5d08ee7ac50eaf4869edaf9f714a"
version = "v1.11.0"
[[projects]]
+ digest = "1:c2a594011eed07da14918c519a5b1d08e4bafb2497037f6a426dc310428df4d3"
name = "github.com/segmentio/ksuid"
packages = ["."]
+ pruneopts = "UT"
revision = "ffd9a8aaaf8f40792e055371eba06542348e991e"
version = "v1.0.2"
[[projects]]
+ digest = "1:5da8ce674952566deae4dbc23d07c85caafc6cfa815b0b3e03e41979cedb8750"
name = "github.com/stretchr/testify"
packages = [
"assert",
- "require"
+ "require",
]
+ pruneopts = "UT"
revision = "ffdc059bfe9ce6a4e144ba849dbedead332c6053"
version = "v1.3.0"
[[projects]]
+ digest = "1:e406c8abe158c24e64775a6381085014943301ffa175a7b53c33cb391ff9b4f2"
name = "github.com/tidwall/gjson"
packages = ["."]
+ pruneopts = "UT"
revision = "5a96cfda705e1762dc0671e26b0b78925ad97e29"
version = "v1.1.5"
[[projects]]
+ digest = "1:8453ddbed197809ee8ca28b06bd04e127bec9912deb4ba451fea7a1eca578328"
name = "github.com/tidwall/match"
packages = ["."]
+ pruneopts = "UT"
revision = "33827db735fff6510490d69a8622612558a557ed"
version = "v1.0.1"
[[projects]]
+ digest = "1:f23222558887a5919f8e9021ecb205395de463f031dd0c049e6e8e547b57c3f4"
name = "github.com/zenazn/goji"
packages = ["web/mutil"]
+ pruneopts = "UT"
revision = "64eb34159fe53473206c2b3e70fe396a639452f2"
version = "v1.0"
[[projects]]
branch = "master"
+ digest = "1:9d2f08c64693fbe7177b5980f80c35672c80f12be79bb3bc86948b934d70e4ee"
name = "golang.org/x/net"
packages = [
"context",
@@ -134,17 +165,21 @@
"http2/hpack",
"idna",
"internal/timeseries",
- "trace"
+ "trace",
]
+ pruneopts = "UT"
revision = "ed066c81e75eba56dd9bd2139ade88125b855585"
[[projects]]
branch = "master"
+ digest = "1:64ec1e1de5cec5e1579df2ff7ac10b20e3bf1cb4393846f631fb204dd9cb44f6"
name = "golang.org/x/sys"
packages = ["unix"]
+ pruneopts = "UT"
revision = "054c452bb702e465e95ce8e7a3d9a6cf0cd1188d"
[[projects]]
+ digest = "1:a2ab62866c75542dd18d2b069fec854577a20211d7c0ea6ae746072a1dccdd18"
name = "golang.org/x/text"
packages = [
"collate",
@@ -160,18 +195,22 @@
"unicode/bidi",
"unicode/cldr",
"unicode/norm",
- "unicode/rangetable"
+ "unicode/rangetable",
]
+ pruneopts = "UT"
revision = "f21a4dfb5e38f5895301dc265a8def02365cc3d0"
version = "v0.3.0"
[[projects]]
branch = "master"
+ digest = "1:077c1c599507b3b3e9156d17d36e1e61928ee9b53a5b420f10f28ebd4a0b275c"
name = "google.golang.org/genproto"
packages = ["googleapis/rpc/status"]
+ pruneopts = "UT"
revision = "db91494dd46c1fdcbbde05e5ff5eb56df8f7d79a"
[[projects]]
+ digest = "1:6dfe7f3314a390dc9e21368dd41236169bf40ae69674f42b7bd45db537751a94"
name = "google.golang.org/grpc"
packages = [
".",
@@ -205,14 +244,34 @@
"resolver/passthrough",
"stats",
"status",
- "tap"
+ "tap",
]
+ pruneopts = "UT"
revision = "a02b0774206b209466313a0b525d2c738fe407eb"
version = "v1.18.0"
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1
- inputs-digest = "ec00bf4786126c0ac9f2050e8dc7e33cac48b415c6035832a24df5a7824f17b0"
+ input-imports = [
+ "github.com/coreos/etcd/clientv3",
+ "github.com/coreos/etcd/clientv3/concurrency",
+ "github.com/coreos/etcd/mvcc/mvccpb",
+ "github.com/gogo/protobuf/proto",
+ "github.com/golang/protobuf/proto",
+ "github.com/heetch/confita",
+ "github.com/heetch/confita/backend",
+ "github.com/heetch/confita/backend/env",
+ "github.com/heetch/confita/backend/flags",
+ "github.com/mattn/go-isatty",
+ "github.com/pkg/errors",
+ "github.com/rs/zerolog",
+ "github.com/rs/zerolog/hlog",
+ "github.com/segmentio/ksuid",
+ "github.com/stretchr/testify/assert",
+ "github.com/stretchr/testify/require",
+ "github.com/tidwall/gjson",
+ "golang.org/x/net/context/ctxhttp",
+ ]
solver-name = "gps-cdcl"
solver-version = 1
diff --git a/store/service.go b/store/service.go
index 0301287..d2a3c03 100644
--- a/store/service.go
+++ b/store/service.go
@@ -46,11 +46,11 @@ type ListOptions struct {
// RulesetEntry holds a ruleset and its metadata.
type RulesetEntry struct {
- Path string
- Version string
- Ruleset *regula.Ruleset
- Signature *regula.Signature
- Versions []string
+ Path string `json:"path"`
+ Version string `json:"version"`
+ Ruleset *regula.Ruleset `json:"rules"`
+ Signature *regula.Signature `json:"signature"`
+ Versions []string `json:"versions"`
}
// RulesetEntries holds a list of ruleset entries.
diff --git a/ui/app/src/views/LatestRuleset/LatestRuleset.vue b/ui/app/src/views/LatestRuleset/LatestRuleset.vue
index 1f13112..c46819e 100644
--- a/ui/app/src/views/LatestRuleset/LatestRuleset.vue
+++ b/ui/app/src/views/LatestRuleset/LatestRuleset.vue
@@ -7,7 +7,9 @@
Parameters
-
+
Return type
-
+
{{ruleset.signature.returnType}}
@@ -49,8 +53,8 @@
diff --git a/ui/app/yarn.lock b/ui/app/yarn.lock
index 924ee56..dbb7924 100644
--- a/ui/app/yarn.lock
+++ b/ui/app/yarn.lock
@@ -1177,7 +1177,7 @@ ajv@^5.2.3, ajv@^5.3.0:
fast-json-stable-stringify "^2.0.0"
json-schema-traverse "^0.3.0"
-ajv@^6.1.0, ajv@^6.5.5:
+ajv@^6.1.0:
version "6.7.0"
resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.7.0.tgz#e3ce7bb372d6577bb1839f1dfdfcbf5ad2948d96"
integrity sha512-RZXPviBTtfmtka9n9sy1N5M5b82CbxWIR6HIis4s3WQTXDJamc/0gpCWNGz6EWdWp4DOfjzJfhz/AS9zVPjjWg==
@@ -1187,6 +1187,16 @@ ajv@^6.1.0, ajv@^6.5.5:
json-schema-traverse "^0.4.1"
uri-js "^4.2.2"
+ajv@^6.5.5:
+ version "6.10.0"
+ resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.10.0.tgz#90d0d54439da587cd7e843bfb7045f50bd22bdf1"
+ integrity sha512-nffhOpkymDECQyR0mnsUtoCE8RlX38G0rYP+wgLWFyZuUyuuojSSvi/+euOiQBIn63whYwYVIIH1TvE3tu4OEg==
+ dependencies:
+ fast-deep-equal "^2.0.1"
+ fast-json-stable-stringify "^2.0.0"
+ json-schema-traverse "^0.4.1"
+ uri-js "^4.2.2"
+
alphanum-sort@^1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/alphanum-sort/-/alphanum-sort-1.0.2.tgz#97a1119649b211ad33691d9f9f486a8ec9fbe0a3"
@@ -1869,11 +1879,6 @@ buffer@^4.3.0:
ieee754 "^1.1.4"
isarray "^1.0.0"
-builtin-modules@^1.0.0:
- version "1.1.1"
- resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-1.1.1.tgz#270f076c5a72c02f5b65a47df94c5fe3a278892f"
- integrity sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=
-
builtin-status-codes@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz#85982878e21b98e1c66425e03d0174788f569ee8"
@@ -4688,13 +4693,6 @@ is-buffer@^1.1.5:
resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.6.tgz#efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be"
integrity sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==
-is-builtin-module@^1.0.0:
- version "1.0.0"
- resolved "https://registry.yarnpkg.com/is-builtin-module/-/is-builtin-module-1.0.0.tgz#540572d34f7ac3119f8f76c30cbc1b1e037affbe"
- integrity sha1-VAVy0096wxGfj3bDDLwbHgN6/74=
- dependencies:
- builtin-modules "^1.0.0"
-
is-callable@^1.1.4:
version "1.1.4"
resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.1.4.tgz#1e1adf219e1eeb684d691f9d6a05ff0d30a24d75"
@@ -5285,12 +5283,7 @@ locate-path@^3.0.0:
p-locate "^3.0.0"
path-exists "^3.0.0"
-lodash.assign@^4.2.0:
- version "4.2.0"
- resolved "https://registry.yarnpkg.com/lodash.assign/-/lodash.assign-4.2.0.tgz#0d99f3ccd7a6d261d19bdaeb9245005d285808e7"
- integrity sha1-DZnzzNem0mHRm9rrkkUAXShYCOc=
-
-lodash.clonedeep@^4.3.2, lodash.clonedeep@^4.5.0:
+lodash.clonedeep@^4.5.0:
version "4.5.0"
resolved "https://registry.yarnpkg.com/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef"
integrity sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8=
@@ -5325,11 +5318,6 @@ lodash.memoize@^4.1.2:
resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe"
integrity sha1-vMbEmkKihA7Zl/Mj6tpezRguC/4=
-lodash.mergewith@^4.6.0:
- version "4.6.1"
- resolved "https://registry.yarnpkg.com/lodash.mergewith/-/lodash.mergewith-4.6.1.tgz#639057e726c3afbdb3e7d42741caa8d6e4335927"
- integrity sha512-eWw5r+PYICtEBgrBE5hhlT6aAa75f411bgDz/ZL2KZqYV03USvucsxcHUIlGTDTECs1eunpI7HOV7U+WLDvNdQ==
-
lodash.sortby@^4.7.0:
version "4.7.0"
resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438"
@@ -5546,12 +5534,24 @@ miller-rabin@^4.0.0:
bn.js "^4.0.0"
brorand "^1.0.1"
+mime-db@1.40.0:
+ version "1.40.0"
+ resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.40.0.tgz#a65057e998db090f732a68f6c276d387d4126c32"
+ integrity sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA==
+
"mime-db@>= 1.36.0 < 2", mime-db@~1.37.0:
version "1.37.0"
resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.37.0.tgz#0b6a0ce6fdbe9576e25f1f2d2fde8830dc0ad0d8"
integrity sha512-R3C4db6bgQhlIhPU48fUtdVmKnflq+hRdad7IyKhtFj06VPNVdk2RhiYL3UjQIlso8L+YxAtFkobT0VK+S/ybg==
-mime-types@^2.1.12, mime-types@~2.1.17, mime-types@~2.1.18, mime-types@~2.1.19:
+mime-types@^2.1.12, mime-types@~2.1.19:
+ version "2.1.24"
+ resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.24.tgz#b6f8d0b3e951efb77dedeca194cff6d16f676f81"
+ integrity sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==
+ dependencies:
+ mime-db "1.40.0"
+
+mime-types@~2.1.17, mime-types@~2.1.18:
version "2.1.21"
resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.21.tgz#28995aa1ecb770742fe6ae7e58f9181c744b3f96"
integrity sha512-3iL6DbwpyLzjR3xHSFNFeb9Nz/M8WDkX33t1GFQnFOllWk8pOrh/LSrB5OXlnlW5P9LH73X6loW/eogc+F5lJg==
@@ -5759,7 +5759,12 @@ mute-stream@0.0.7:
resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.7.tgz#3075ce93bc21b8fab43e1bc4da7e8115ed1e7bab"
integrity sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=
-nan@^2.10.0, nan@^2.9.2:
+nan@^2.13.2:
+ version "2.13.2"
+ resolved "https://registry.yarnpkg.com/nan/-/nan-2.13.2.tgz#f51dc7ae66ba7d5d55e1e6d4d8092e802c9aefe7"
+ integrity sha512-TghvYc72wlMGMVMluVo9WRJc0mB8KxxF/gZ4YYFy7V2ZQX9l7rgbPg7vjS9mt6U5HXODVFVI2bOduCzwOMv/lw==
+
+nan@^2.9.2:
version "2.12.1"
resolved "https://registry.yarnpkg.com/nan/-/nan-2.12.1.tgz#7b1aa193e9aa86057e3c7bbd0ac448e770925552"
integrity sha512-JY7V6lRkStKcKTvHO5NVSQRv+RV+FIL5pvDoLiAtSL9pKlC5x9PKQcZDsq7m4FO4d57mkhC6Z+QhAh3Jdk5JFw==
@@ -5902,9 +5907,9 @@ node-releases@^1.1.3:
semver "^5.3.0"
node-sass@^4.9.0:
- version "4.11.0"
- resolved "https://registry.yarnpkg.com/node-sass/-/node-sass-4.11.0.tgz#183faec398e9cbe93ba43362e2768ca988a6369a"
- integrity sha512-bHUdHTphgQJZaF1LASx0kAviPH7sGlcyNhWade4eVIpFp6tsn7SV8xNMTbsQFpEV9VXpnwTTnNYlfsZXgGgmkA==
+ version "4.12.0"
+ resolved "https://registry.yarnpkg.com/node-sass/-/node-sass-4.12.0.tgz#0914f531932380114a30cc5fa4fa63233a25f017"
+ integrity sha512-A1Iv4oN+Iel6EPv77/HddXErL2a+gZ4uBeZUy+a8O35CFYTXhgA8MgLCWBtwpGZdCvTvQ9d+bQxX/QC36GDPpQ==
dependencies:
async-foreach "^0.1.3"
chalk "^1.1.1"
@@ -5913,12 +5918,10 @@ node-sass@^4.9.0:
get-stdin "^4.0.1"
glob "^7.0.3"
in-publish "^2.0.0"
- lodash.assign "^4.2.0"
- lodash.clonedeep "^4.3.2"
- lodash.mergewith "^4.6.0"
+ lodash "^4.17.11"
meow "^3.7.0"
mkdirp "^0.5.1"
- nan "^2.10.0"
+ nan "^2.13.2"
node-gyp "^3.8.0"
npmlog "^4.0.0"
request "^2.88.0"
@@ -5947,12 +5950,12 @@ nopt@^4.0.1:
osenv "^0.1.4"
normalize-package-data@^2.3.2, normalize-package-data@^2.3.4:
- version "2.4.0"
- resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.4.0.tgz#12f95a307d58352075a04907b84ac8be98ac012f"
- integrity sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==
+ version "2.5.0"
+ resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.5.0.tgz#e66db1838b200c1dfc233225d12cb36520e234a8"
+ integrity sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==
dependencies:
hosted-git-info "^2.1.4"
- is-builtin-module "^1.0.0"
+ resolve "^1.10.0"
semver "2 || 3 || 4 || 5"
validate-npm-package-license "^3.0.1"
@@ -7341,6 +7344,13 @@ resolve-url@^0.2.1:
resolved "https://registry.yarnpkg.com/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a"
integrity sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=
+resolve@^1.10.0:
+ version "1.10.1"
+ resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.10.1.tgz#664842ac960795bbe758221cdccda61fb64b5f18"
+ integrity sha512-KuIe4mf++td/eFb6wkaPbMDnP6kObCaEtIDuHOUED6MNUo4K670KZUHuuvYPZDxNF0WVLw49n06M2m2dXphEzA==
+ dependencies:
+ path-parse "^1.0.6"
+
resolve@^1.3.2, resolve@^1.4.0, resolve@^1.5.0, resolve@^1.8.1, resolve@^1.9.0:
version "1.10.0"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.10.0.tgz#3bdaaeaf45cc07f375656dfd2e54ed0810b101ba"
@@ -7510,7 +7520,12 @@ selfsigned@^1.9.1:
dependencies:
node-forge "0.7.5"
-"semver@2 || 3 || 4 || 5", semver@^5.3.0, semver@^5.4.1, semver@^5.5.0, semver@^5.5.1, semver@^5.6.0:
+"semver@2 || 3 || 4 || 5":
+ version "5.7.0"
+ resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.0.tgz#790a7cf6fea5459bac96110b29b60412dc8ff96b"
+ integrity sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA==
+
+semver@^5.3.0, semver@^5.4.1, semver@^5.5.0, semver@^5.5.1, semver@^5.6.0:
version "5.6.0"
resolved "https://registry.yarnpkg.com/semver/-/semver-5.6.0.tgz#7e74256fbaa49c75aa7c7a205cc22799cac80004"
integrity sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==
@@ -7807,9 +7822,9 @@ spdx-expression-parse@^3.0.0:
spdx-license-ids "^3.0.0"
spdx-license-ids@^3.0.0:
- version "3.0.3"
- resolved "https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-3.0.3.tgz#81c0ce8f21474756148bbb5f3bfc0f36bf15d76e"
- integrity sha512-uBIcIl3Ih6Phe3XHK1NqboJLdGfwr1UN3k6wSD1dZpmPsIkb8AGNbZYJ1fOBk834+Gxy8rpfDxrS6XLEMZMY2g==
+ version "3.0.4"
+ resolved "https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-3.0.4.tgz#75ecd1a88de8c184ef015eafb51b5b48bfd11bb1"
+ integrity sha512-7j8LYJLeY/Yb6ACbQ7F76qy5jHkp0U6jgBfJsk97bwWlVUnUWsAgpyaCvo17h0/RQGnQ036tVDomiwoI4pDkQA==
spdy-transport@^3.0.0:
version "3.0.0"
@@ -7847,9 +7862,9 @@ sprintf-js@~1.0.2:
integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=
sshpk@^1.7.0:
- version "1.16.0"
- resolved "https://registry.yarnpkg.com/sshpk/-/sshpk-1.16.0.tgz#1d4963a2fbffe58050aa9084ca20be81741c07de"
- integrity sha512-Zhev35/y7hRMcID/upReIvRse+I9SVhyVre/KTJSJQWMz3C3+G+HpO7m1wK/yckEtujKZ7dS4hkVxAnmHaIGVQ==
+ version "1.16.1"
+ resolved "https://registry.yarnpkg.com/sshpk/-/sshpk-1.16.1.tgz#fb661c0bef29b39db40769ee39fa70093d6f6877"
+ integrity sha512-HXXqVUq7+pcKeLqqZj6mHFUMvXtOJt1uoUx09pFW6011inTMxqI8BA8PM95myrIyyKwdnzjdFjLiE6KBPVtJIg==
dependencies:
asn1 "~0.2.3"
assert-plus "^1.0.0"
diff --git a/ui/handler.go b/ui/handler.go
index e78a4ab..3577ac6 100644
--- a/ui/handler.go
+++ b/ui/handler.go
@@ -8,6 +8,7 @@ import (
"io"
"net/http"
"strconv"
+ "strings"
"github.com/heetch/regula"
reghttp "github.com/heetch/regula/http"
@@ -120,6 +121,58 @@ func (h *internalHandler) handleNewRulesetRequest(w http.ResponseWriter, r *http
}
+func (h *internalHandler) handleSingleRuleset(w http.ResponseWriter, r *http.Request) {
+ path := strings.TrimPrefix(r.URL.Path, "/rulesets/")
+
+ if path == "" {
+ h.handleListRequest(w, r)
+ return
+ }
+ srr := &singleRulesetResponse{
+ Path: path,
+ }
+
+ entry, err := h.service.Get(r.Context(), path, "")
+ if err != nil {
+ if err == store.ErrNotFound {
+ writeError(w, r, err, http.StatusNotFound)
+ return
+ }
+
+ writeError(w, r, err, http.StatusInternalServerError)
+ return
+ }
+ srr.Version = entry.Version
+ srr.Versions = entry.Versions
+ srr.Signature = signature{
+ ReturnType: entry.Signature.ReturnType,
+ }
+ for name, typ := range entry.Signature.ParamTypes {
+ srr.Signature.Params = append(srr.Signature.Params,
+ param{"name": name, "type": typ})
+ }
+ for _, ri := range entry.Ruleset.Rules {
+ sv, err := sexpr.PrettyPrint(0, 80, ri.Expr)
+ if err != nil {
+ writeError(w, r, err, http.StatusInternalServerError)
+ return
+ }
+ rv, err := sexpr.PrettyPrint(0, 80, ri.Result)
+ if err != nil {
+ writeError(w, r, err, http.StatusInternalServerError)
+ return
+ }
+
+ o := rule{
+ SExpr: sv,
+ ReturnValue: rv,
+ }
+ srr.Ruleset = append(srr.Ruleset, o)
+ }
+
+ reghttp.EncodeJSON(w, r, srr, http.StatusOK)
+}
+
// handleListRequest attempts to return a list of Rulesets based on the data provided in a GET request to the ruleset endpoint.
func (h *internalHandler) handleListRequest(w http.ResponseWriter, r *http.Request) {
type ruleset struct {
@@ -166,30 +219,15 @@ func (h *internalHandler) rulesetsHandler() http.Handler {
case "POST":
h.handleNewRulesetRequest(w, r)
case "GET":
- h.handleListRequest(w, r)
+ if _, ok := r.URL.Query()["list"]; ok {
+ h.handleListRequest(w, r)
+ return
+ }
+ h.handleSingleRuleset(w, r)
}
})
}
-type param map[string]string
-
-type signature struct {
- Params []param `json:"params"`
- ReturnType string
-}
-
-type rule struct {
- SExpr string `json:"sExpr"`
- ReturnValue string `json:"returnValue"`
-}
-
-// newRulesetRequest is the unmarshaled form a new ruleset request.
-type newRulesetRequest struct {
- Path string `json:"path"`
- Signature signature `json:"signature"`
- Rules []rule `json:"rules"`
-}
-
// convertParams takes a slice of param, unmarshalled from a
// newRulesetRequest, and returns an equivalent sexpr.Parameters map.
func convertParams(input []param) (sexpr.Parameters, error) {
@@ -340,3 +378,30 @@ func (re RuleError) MarshalJSON() ([]byte, error) {
}
return json.Marshal(err)
}
+
+type param map[string]string
+
+type signature struct {
+ Params []param `json:"params"`
+ ReturnType string `json:"returnType"`
+}
+
+type rule struct {
+ SExpr string `json:"sExpr"`
+ ReturnValue string `json:"returnValue"`
+}
+
+// newRulesetRequest is the unmarshaled form a new ruleset request.
+type newRulesetRequest struct {
+ Path string `json:"path"`
+ Signature signature `json:"signature"`
+ Rules []rule `json:"rules"`
+}
+
+type singleRulesetResponse struct {
+ Path string `json:"path"`
+ Version string `json:"version"`
+ Ruleset []rule `json:"rules"`
+ Signature signature `json:"signature"`
+ Versions []string `json:"versions"`
+}
diff --git a/ui/handler_test.go b/ui/handler_test.go
index 8574311..8e1221f 100644
--- a/ui/handler_test.go
+++ b/ui/handler_test.go
@@ -2,6 +2,7 @@ package ui
import (
"context"
+ "encoding/json"
"errors"
"fmt"
"io"
@@ -10,6 +11,7 @@ import (
"strings"
"testing"
+ "github.com/heetch/regula"
"github.com/heetch/regula/mock"
regrule "github.com/heetch/regula/rule"
"github.com/heetch/regula/rule/sexpr"
@@ -219,3 +221,52 @@ func TestConvertParams(t *testing.T) {
})
}
}
+
+func TestSingleRulesetHandler(t *testing.T) {
+ s := new(mock.RulesetService)
+
+ s.GetFn = func(ctx context.Context, path, v string) (*store.RulesetEntry, error) {
+ require.Equal(t, "a/nice/ruleset", path)
+
+ entry := &store.RulesetEntry{
+ Path: path,
+ Version: "2",
+ Ruleset: ®ula.Ruleset{
+ Rules: []*regrule.Rule{
+ ®rule.Rule{
+ Expr: regrule.BoolValue(true),
+ Result: regrule.StringValue("Hello"),
+ },
+ },
+ Type: "string",
+ }, // *regula.Ruleset
+ Signature: ®ula.Signature{
+ ParamTypes: map[string]string{
+ "foo": "int64",
+ "bar": "string",
+ },
+ ReturnType: "string",
+ }, //*regula.Signature
+ Versions: []string{"1", "2"},
+ }
+ return entry, nil
+ }
+ defer func() { s.GetFn = nil }()
+
+ rec := doRequest(NewHandler(s, http.Dir("")), "GET", "/i/rulesets/a/nice/ruleset", nil)
+ require.Equal(t, http.StatusOK, rec.Code)
+ body := rec.Body.Bytes()
+ // Note: we could use require.JSONEq here, but the ordering of
+ // params and rules are not stable and JSONEq can't cope with
+ // disparate ordering.
+ srr := &singleRulesetResponse{}
+ err := json.Unmarshal(body, srr)
+ require.NoError(t, err)
+ require.Equal(t, "a/nice/ruleset", srr.Path)
+ require.Equal(t, "2", srr.Version)
+ require.Equal(t, []rule{{SExpr: "#true", ReturnValue: "\"Hello\""}}, srr.Ruleset)
+ require.Contains(t, srr.Signature.Params, param{"name": "foo", "type": "int64"})
+ require.Contains(t, srr.Signature.Params, param{"name": "bar", "type": "string"})
+ require.Equal(t, "string", srr.Signature.ReturnType)
+ require.Equal(t, 1, s.GetCount)
+}