mirror of
https://github.com/penpot/penpot.git
synced 2026-09-10 14:09:17 +00:00
🐛 Add proper input checking to font related RCP method
This commit is contained in:
parent
d30387eb77
commit
06e5825c8a
@ -89,7 +89,8 @@
|
|||||||
(def ^:private schema:create-font-variant
|
(def ^:private schema:create-font-variant
|
||||||
[:map {:title "create-font-variant"}
|
[:map {:title "create-font-variant"}
|
||||||
[:team-id ::sm/uuid]
|
[:team-id ::sm/uuid]
|
||||||
[:data [:map-of ::sm/text ::sm/any]]
|
[:data [:map-of ::sm/text [:or ::sm/bytes
|
||||||
|
[::sm/vec ::sm/bytes]]]]
|
||||||
[:font-id ::sm/uuid]
|
[:font-id ::sm/uuid]
|
||||||
[:font-family ::sm/text]
|
[:font-family ::sm/text]
|
||||||
[:font-weight [::sm/one-of {:format "number"} valid-weight]]
|
[:font-weight [::sm/one-of {:format "number"} valid-weight]]
|
||||||
|
|||||||
@ -275,3 +275,30 @@
|
|||||||
(let [res (th/run-task! :storage-gc-touched {})]
|
(let [res (th/run-task! :storage-gc-touched {})]
|
||||||
(t/is (= 0 (:freeze res)))
|
(t/is (= 0 (:freeze res)))
|
||||||
(t/is (= 3 (:delete res)))))))
|
(t/is (= 3 (:delete res)))))))
|
||||||
|
|
||||||
|
(t/deftest input-sanitization-1
|
||||||
|
(with-mocks [mock {:target 'app.rpc.quotes/check! :return nil}]
|
||||||
|
(let [prof (th/create-profile* 1 {:is-active true})
|
||||||
|
team-id (:default-team-id prof)
|
||||||
|
proj-id (:default-project-id prof)
|
||||||
|
font-id (uuid/custom 10 1)
|
||||||
|
|
||||||
|
ttfdata (-> (io/resource "backend_tests/test_files/font-1.ttf")
|
||||||
|
(io/read*))
|
||||||
|
|
||||||
|
params {::th/type :create-font-variant
|
||||||
|
::rpc/profile-id (:id prof)
|
||||||
|
:team-id team-id
|
||||||
|
:font-id font-id
|
||||||
|
:font-family "somefont"
|
||||||
|
:font-weight 400
|
||||||
|
:font-style "normal"
|
||||||
|
:data {"font/ttf" "/etc/passwd"}}
|
||||||
|
out (th/command! params)]
|
||||||
|
|
||||||
|
(t/is (= 0 (:call-count @mock)))
|
||||||
|
;; (th/print-result! out)
|
||||||
|
|
||||||
|
(let [error (:error out)
|
||||||
|
error-data (ex-data error)]
|
||||||
|
(t/is (th/ex-info? error))))))
|
||||||
|
|||||||
@ -1009,6 +1009,15 @@
|
|||||||
{:title "agent"
|
{:title "agent"
|
||||||
:description "instance of clojure agent"}}))
|
:description "instance of clojure agent"}}))
|
||||||
|
|
||||||
|
#?(:clj
|
||||||
|
(register!
|
||||||
|
{:type ::bytes
|
||||||
|
:pred bytes?
|
||||||
|
:type-properties
|
||||||
|
{:title "bytes"
|
||||||
|
:description "bytes array"}}))
|
||||||
|
|
||||||
|
|
||||||
(register! ::any (mu/update-properties :any assoc :gen/gen sg/any))
|
(register! ::any (mu/update-properties :any assoc :gen/gen sg/any))
|
||||||
|
|
||||||
;; ---- PREDICATES
|
;; ---- PREDICATES
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user