blob: 3d11816144f4fdc9a1249344fd351a0dad4f64f8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
(.module:
[lux #*
[control
[security
["." integrity (#+ Dirty)]]]
[data
["." text]
[format
[context (#+ Context)]]
[collection
["." dictionary]]]
[io (#- run)]
[host (#+ import:)]])
## Do not trust the values of environment variables
## https://wiki.sei.cmu.edu/confluence/display/java/ENV02-J.+Do+not+trust+the+values+of+environment+variables
(import: java/lang/String)
(import: (java/util/Map$Entry k v)
(getKey [] k)
(getValue [] v))
(import: (java/util/Iterator a)
(hasNext [] boolean)
(next [] a))
(import: (java/util/Set a)
(iterator [] (Iterator a)))
(import: (java/util/Map k v)
(entrySet [] (Set (Map$Entry k v))))
(import: java/lang/System
(#static getenv [] (Map String String)))
(def: (consume-iterator f iterator)
(All [a b] (-> (-> a b) (Iterator a) (List b)))
(if (Iterator::hasNext iterator)
(#.Cons (f (Iterator::next iterator))
(consume-iterator f iterator))
#.Nil))
(def: (entry-to-kv entry)
(All [k v] (-> (Map$Entry k v) [k v]))
[(Map$Entry::getKey entry)
(Map$Entry::getValue entry)])
(def: #export read
(IO (Dirty Context))
(io (|> (System::getenv)
Map::entrySet
Set::iterator
(consume-iterator entry-to-kv)
(dictionary.from-list text.hash)
integrity.taint)))
|