Skip to content

Commit 935e295

Browse files
author
Derek Dagit
committed
Revert "check file download path for security"
This reverts commit 6a421d5.
1 parent 6a421d5 commit 935e295

File tree

2 files changed

+36
-54
lines changed

2 files changed

+36
-54
lines changed

storm-core/src/clj/backtype/storm/daemon/nimbus.clj

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -881,17 +881,6 @@
881881
(throw (InvalidTopologyException.
882882
(str "Topology name cannot contain any of the following: " (pr-str DISALLOWED-TOPOLOGY-NAME-STRS))))))
883883

884-
(defn check-file-location! [conf file-path]
885-
(log-debug "check file location:" file-path)
886-
(if (clojure.string/blank? file-path)
887-
(throw (AuthorizationException. (str "Invalid file path:" file-path))))
888-
(let [stormdist-dir (str (master-stormdist-root conf) "/")
889-
stormdist-dir-len (.length stormdist-dir)
890-
file-path-len (.length file-path)
891-
file-path-prefix (if (> file-path-len stormdist-dir-len) (.substring file-path 0 stormdist-dir-len))]
892-
(if (not= (compare stormdist-dir file-path-prefix) 0)
893-
(throw (AuthorizationException. (str "Invalid file path:" file-path))))))
894-
895884
(defn- try-read-storm-conf [conf storm-id]
896885
(try-cause
897886
(read-storm-conf conf storm-id)
@@ -1095,7 +1084,6 @@
10951084
))
10961085

10971086
(^String beginFileDownload [this ^String file]
1098-
(check-file-location! (:conf nimbus) file)
10991087
(check-authorization! nimbus nil nil "fileDownload")
11001088
(let [is (BufferFileInputStream. file)
11011089
id (uuid)]

storm-core/test/clj/backtype/storm/nimbus_test.clj

Lines changed: 36 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -146,13 +146,7 @@
146146
(is (not-nil? ((:executor->start-time-secs assignment) e))))
147147
))
148148

149-
(deftest test-file-bogus-bogus-download
150-
(with-local-cluster [cluster :daemon-conf {SUPERVISOR-ENABLE false TOPOLOGY-ACKER-EXECUTORS 0}]
151-
(let [nimbus (:nimbus cluster)]
152-
(is (thrown? AuthorizationException (.beginFileDownload nimbus nil)))
153-
(is (thrown? AuthorizationException (.beginFileDownload nimbus "")))
154-
(is (thrown? AuthorizationException (.beginFileDownload nimbus "/bogus-path/foo")))
155-
)))
149+
156150

157151
(deftest test-bogusId
158152
(with-local-cluster [cluster :supervisors 4 :ports-per-supervisor 3 :daemon-conf {SUPERVISOR-ENABLE false TOPOLOGY-ACKER-EXECUTORS 0}]
@@ -234,7 +228,7 @@
234228
{"1" (thrift/mk-spout-spec (TestPlannerSpout. false) :parallelism-hint 3)}
235229
{"2" (thrift/mk-bolt-spec {"1" :none} (TestPlannerBolt.) :parallelism-hint 5)
236230
"3" (thrift/mk-bolt-spec {"2" :none} (TestPlannerBolt.))}))
237-
231+
238232
(submit-local-topology nimbus "noniso" {TOPOLOGY-OPTIMIZE false TOPOLOGY-WORKERS 4} topology)
239233
(advance-cluster-time cluster 1)
240234
(is (= 4 (topology-num-nodes state "noniso")))
@@ -243,32 +237,32 @@
243237
(submit-local-topology nimbus "tester1" {TOPOLOGY-OPTIMIZE false TOPOLOGY-WORKERS 6} topology)
244238
(submit-local-topology nimbus "tester2" {TOPOLOGY-OPTIMIZE false TOPOLOGY-WORKERS 6} topology)
245239
(advance-cluster-time cluster 1)
246-
240+
247241
(bind task-info-tester1 (storm-component->task-info cluster "tester1"))
248242
(bind task-info-tester2 (storm-component->task-info cluster "tester2"))
249-
243+
250244

251245
(is (= 1 (topology-num-nodes state "noniso")))
252246
(is (= 3 (storm-num-workers state "noniso")))
253247

254248
(is (= {2 3} (topology-node-distribution state "tester1")))
255249
(is (= {3 2} (topology-node-distribution state "tester2")))
256-
250+
257251
(is (apply disjoint? (map (partial topology-nodes state) ["noniso" "tester1" "tester2"])))
258-
252+
259253
(check-consistency cluster "tester1")
260254
(check-consistency cluster "tester2")
261255
(check-consistency cluster "noniso")
262256

263257
;;check that nothing gets reassigned
264258
(bind tester1-slots (topology-slots state "tester1"))
265259
(bind tester2-slots (topology-slots state "tester2"))
266-
(bind noniso-slots (topology-slots state "noniso"))
260+
(bind noniso-slots (topology-slots state "noniso"))
267261
(advance-cluster-time cluster 20)
268262
(is (= tester1-slots (topology-slots state "tester1")))
269263
(is (= tester2-slots (topology-slots state "tester2")))
270264
(is (= noniso-slots (topology-slots state "noniso")))
271-
265+
272266
)))
273267

274268
(deftest test-zero-executor-or-tasks
@@ -302,7 +296,7 @@
302296
(check-consistency cluster "mystorm")
303297
(is (= 5 (count (task-info "1"))))
304298
(check-distribution (executor-info "1") [2 2 1])
305-
299+
306300
(is (= 2 (count (task-info "2"))))
307301
(check-distribution (executor-info "2") [1 1])
308302

@@ -375,13 +369,13 @@
375369
(is (thrown? AlreadyAliveException (submit-local-topology (:nimbus cluster) "2test" {} topology)))
376370
(advance-cluster-time cluster 5)
377371
(is (= 1 (count (.heartbeat-storms state))))
378-
372+
379373
(advance-cluster-time cluster 6)
380374
(is (nil? (.storm-base state storm-id nil)))
381375
(is (nil? (.assignment-info state storm-id nil)))
382376
(advance-cluster-time cluster 11)
383377
(is (= 0 (count (.heartbeat-storms state))))
384-
378+
385379
(submit-local-topology (:nimbus cluster) "test3" {TOPOLOGY-MESSAGE-TIMEOUT-SECS 5} topology)
386380
(bind storm-id3 (get-storm-id state "test3"))
387381
(advance-cluster-time cluster 1)
@@ -395,12 +389,12 @@
395389
;; this guarantees that monitor thread won't trigger for 10 more seconds
396390
(advance-time-secs! 11)
397391
(wait-until-cluster-waiting cluster)
398-
392+
399393
(submit-local-topology (:nimbus cluster) "test3" {TOPOLOGY-MESSAGE-TIMEOUT-SECS 5} topology)
400394
(bind storm-id3 (get-storm-id state "test3"))
401395

402396
(bind executor-id (first (topology-executors cluster storm-id3)))
403-
397+
404398
(do-executor-heartbeat cluster storm-id3 executor-id)
405399

406400
(.killTopology (:nimbus cluster) "test3")
@@ -416,7 +410,7 @@
416410
(advance-cluster-time cluster 9)
417411
(is (not-nil? (.assignment-info state storm-id4 nil)))
418412
(advance-cluster-time cluster 2)
419-
(is (nil? (.assignment-info state storm-id4 nil)))
413+
(is (nil? (.assignment-info state storm-id4 nil)))
420414
)))
421415

422416
(deftest test-reassignment
@@ -440,7 +434,7 @@
440434
(bind [executor-id1 executor-id2] (topology-executors cluster storm-id))
441435
(bind ass1 (executor-assignment cluster storm-id executor-id1))
442436
(bind ass2 (executor-assignment cluster storm-id executor-id2))
443-
437+
444438
(advance-cluster-time cluster 59)
445439
(do-executor-heartbeat cluster storm-id executor-id1)
446440
(do-executor-heartbeat cluster storm-id executor-id2)
@@ -461,7 +455,7 @@
461455
(do-executor-heartbeat cluster storm-id executor-id1)
462456
(is (= ass1 (executor-assignment cluster storm-id executor-id1)))
463457
(check-consistency cluster "test")
464-
458+
465459
(advance-cluster-time cluster 11)
466460
(is (= ass1 (executor-assignment cluster storm-id executor-id1)))
467461
(is (not= ass2 (executor-assignment cluster storm-id executor-id2)))
@@ -537,7 +531,7 @@
537531
(bind [executor-id1 executor-id2] (topology-executors cluster storm-id))
538532
(bind ass1 (executor-assignment cluster storm-id executor-id1))
539533
(bind ass2 (executor-assignment cluster storm-id executor-id2))
540-
534+
541535
(advance-cluster-time cluster 59)
542536
(do-executor-heartbeat cluster storm-id executor-id1)
543537
(do-executor-heartbeat cluster storm-id executor-id2)
@@ -609,7 +603,7 @@
609603
(bind common (first (find-first (fn [[k v]] (= 3 (count v))) slot-executors2)))
610604
(is (not-nil? common))
611605
(is (= (slot-executors2 common) (slot-executors common)))
612-
606+
613607
;; check that start times are changed for everything but the common one
614608
(bind same-executors (slot-executors2 common))
615609
(bind changed-executors (apply concat (vals (dissoc slot-executors2 common))))
@@ -655,7 +649,7 @@
655649
(bind slot-executors (slot-assignments cluster storm-id))
656650
(check-executor-distribution slot-executors [1 1 1])
657651
(check-num-nodes slot-executors 3)
658-
652+
659653
(is (thrown? InvalidTopologyException
660654
(.rebalance (:nimbus cluster) "test"
661655
(doto (RebalanceOptions.)
@@ -685,7 +679,7 @@
685679
(slot-assignments cluster storm-id)
686680
distribution)))
687681
(checker [2 2 2])
688-
682+
689683
(.rebalance (:nimbus cluster) "test"
690684
(doto (RebalanceOptions.)
691685
(.set_num_workers 6)
@@ -694,7 +688,7 @@
694688
(checker [2 2 2])
695689
(advance-cluster-time cluster 3)
696690
(checker [1 1 1 1 1 1])
697-
691+
698692
(.rebalance (:nimbus cluster) "test"
699693
(doto (RebalanceOptions.)
700694
(.set_num_executors {"1" 1})
@@ -712,11 +706,11 @@
712706
(advance-cluster-time cluster 32)
713707
(checker [2 2 2 2])
714708
(check-consistency cluster "test")
715-
709+
716710
(bind executor-info (->> (storm-component->executor-info cluster "test")
717711
(map-val #(map executor-id->tasks %))))
718712
(check-distribution (executor-info "1") [2 2 2 2 1 1 1 1])
719-
713+
720714
)))
721715

722716
(deftest test-submit-invalid
@@ -729,13 +723,13 @@
729723
(bind topology (thrift/mk-topology
730724
{"1" (thrift/mk-spout-spec (TestPlannerSpout. true) :parallelism-hint 0 :conf {TOPOLOGY-TASKS 1})}
731725
{}))
732-
726+
733727
(is (thrown? InvalidTopologyException
734728
(submit-local-topology (:nimbus cluster)
735729
"test"
736730
{}
737731
topology)))
738-
732+
739733
(bind topology (thrift/mk-topology
740734
{"1" (thrift/mk-spout-spec (TestPlannerSpout. true) :parallelism-hint 1 :conf {TOPOLOGY-TASKS 1})}
741735
{}))
@@ -753,7 +747,7 @@
753747
(is (thrown? InvalidTopologyException
754748
(submit-local-topology (:nimbus cluster)
755749
"test"
756-
{TOPOLOGY-WORKERS 3}
750+
{TOPOLOGY-WORKERS 3}
757751
topology)))
758752
(bind topology (thrift/mk-topology
759753
{"1" (thrift/mk-spout-spec (TestPlannerSpout. true)
@@ -838,32 +832,32 @@
838832
))))
839833

840834
(deftest test-nimbus-iface-submitTopologyWithOpts-checks-authorization
841-
(with-local-cluster [cluster
842-
:daemon-conf {NIMBUS-AUTHORIZER
835+
(with-local-cluster [cluster
836+
:daemon-conf {NIMBUS-AUTHORIZER
843837
"backtype.storm.security.auth.authorizer.DenyAuthorizer"}]
844838
(let [
845839
nimbus (:nimbus cluster)
846840
topology (thrift/mk-topology {} {})
847841
]
848842
(is (thrown? AuthorizationException
849-
(submit-local-topology-with-opts nimbus "mystorm" {} topology
843+
(submit-local-topology-with-opts nimbus "mystorm" {} topology
850844
(SubmitOptions. TopologyInitialStatus/INACTIVE))
851845
))
852846
)
853847
)
854848
)
855849

856850
(deftest test-nimbus-iface-methods-check-authorization
857-
(with-local-cluster [cluster
858-
:daemon-conf {NIMBUS-AUTHORIZER
851+
(with-local-cluster [cluster
852+
:daemon-conf {NIMBUS-AUTHORIZER
859853
"backtype.storm.security.auth.authorizer.DenyAuthorizer"}]
860854
(let [
861855
nimbus (:nimbus cluster)
862856
topology (thrift/mk-topology {} {})
863857
]
864858
; Fake good authorization as part of setup.
865859
(mocking [nimbus/check-authorization!]
866-
(submit-local-topology-with-opts nimbus "test" {} topology
860+
(submit-local-topology-with-opts nimbus "test" {} topology
867861
(SubmitOptions. TopologyInitialStatus/INACTIVE))
868862
)
869863
(stubbing [nimbus/storm-active? true]
@@ -939,16 +933,16 @@
939933
(stubbing [topology-bases bogus-bases]
940934
(let [topos (.get_topologies (.getClusterInfo nimbus))]
941935
; The number of topologies in the summary is correct.
942-
(is (= (count
936+
(is (= (count
943937
(filter (fn [b] (second b)) bogus-bases)) (count topos)))
944938
; Each topology present has a valid name.
945939
(is (empty?
946940
(filter (fn [t] (or (nil? t) (nil? (.get_name t)))) topos)))
947941
; The topologies are those with valid bases.
948942
(is (empty?
949-
(filter (fn [t]
950-
(or
951-
(nil? t)
943+
(filter (fn [t]
944+
(or
945+
(nil? t)
952946
(not (number? (read-string (.get_id t))))
953947
(odd? (read-string (.get_id t)))
954948
)) topos)))

0 commit comments

Comments
 (0)