diff --git a/backend/src/app/rpc/commands/fonts.clj b/backend/src/app/rpc/commands/fonts.clj index 8ca20eac49..03c66a968f 100644 --- a/backend/src/app/rpc/commands/fonts.clj +++ b/backend/src/app/rpc/commands/fonts.clj @@ -89,7 +89,8 @@ (def ^:private schema:create-font-variant [:map {:title "create-font-variant"} [: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-family ::sm/text] [:font-weight [::sm/one-of {:format "number"} valid-weight]] diff --git a/backend/test/backend_tests/rpc_font_test.clj b/backend/test/backend_tests/rpc_font_test.clj index ef19218314..24697ef8d8 100644 --- a/backend/test/backend_tests/rpc_font_test.clj +++ b/backend/test/backend_tests/rpc_font_test.clj @@ -275,3 +275,30 @@ (let [res (th/run-task! :storage-gc-touched {})] (t/is (= 0 (:freeze 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)))))) diff --git a/common/src/app/common/schema.cljc b/common/src/app/common/schema.cljc index 6c4ecb6ef1..e04307bba8 100644 --- a/common/src/app/common/schema.cljc +++ b/common/src/app/common/schema.cljc @@ -1009,6 +1009,15 @@ {:title "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)) ;; ---- PREDICATES