From 7c0793c86076d4f19083a3a0a699de4f1e1661b4 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Thu, 12 Jan 2017 19:39:49 -0400 Subject: - Added a module for tainting data. --- stdlib/source/lux/data/taint.lux | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 stdlib/source/lux/data/taint.lux diff --git a/stdlib/source/lux/data/taint.lux b/stdlib/source/lux/data/taint.lux new file mode 100644 index 000000000..935d16c72 --- /dev/null +++ b/stdlib/source/lux/data/taint.lux @@ -0,0 +1,30 @@ +## Copyright (c) Eduardo Julian. All rights reserved. +## This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. +## If a copy of the MPL was not distributed with this file, +## You can obtain one at http://mozilla.org/MPL/2.0/. + +(;module: + lux + (lux (data [product]))) + +(type: #export (Tainted a) + [a Void]) + +(def: #export (taint input) + (All [a] (-> a (Tainted a))) + [input (:! Void [])]) + +(def: #export (trust input) + (All [a] (-> (Tainted a) a)) + (product;left input)) + +(def: #export (validate pred input) + (All [a] (-> (-> a Bool) (Tainted a) (Maybe a))) + (let [value (product;left input)] + (if (pred value) + (#;Some value) + #;None))) + +(def: #export (sanitize f input) + (All [a] (-> (-> a a) (Tainted a) a)) + (|> input product;left f)) -- cgit v1.2.3