diff options
author | kaotisk <kaotisk@arching-kaos.org> | 2024-06-04 03:30:10 +0300 |
---|---|---|
committer | kaotisk <kaotisk@arching-kaos.org> | 2024-06-04 03:30:10 +0300 |
commit | 40206d2ede1c9963c4e4f718e1e203e5d901af73 (patch) | |
tree | 06f185de3bf8ca6b903b85e184c30e64afc75e75 /api/routes | |
parent | b35833cadff3a4e9346cb97ae3628f6c5b4e6bf9 (diff) | |
download | arching-kaos-tools-40206d2ede1c9963c4e4f718e1e203e5d901af73.tar.gz arching-kaos-tools-40206d2ede1c9963c4e4f718e1e203e5d901af73.tar.bz2 arching-kaos-tools-40206d2ede1c9963c4e4f718e1e203e5d901af73.zip |
Extra validation
Diffstat (limited to 'api/routes')
-rw-r--r-- | api/routes/announceZBlock/index.js | 8 | ||||
-rw-r--r-- | api/routes/announceZChain/index.js | 7 | ||||
-rw-r--r-- | api/routes/getInnerIPFSContent/index.js | 9 |
3 files changed, 13 insertions, 11 deletions
diff --git a/api/routes/announceZBlock/index.js b/api/routes/announceZBlock/index.js index b395dbf..254e1dc 100644 --- a/api/routes/announceZBlock/index.js +++ b/api/routes/announceZBlock/index.js @@ -15,11 +15,11 @@ const getvalidity = require('../../validators/ZblockValidator') module.exports = (req, res) => { console.log(req); - console.log("okay we got called"); - if ( (req.body.zblock) && req.body.zblock.length === 46 ){ + if ( (req.body.zblock) && typeof req.body.zblock === "string" && req.body.zblock.length === 46 ){ + let zblock = req.body.zblock; regex= /Qm[A-Za-z0-9]{44}/; - if (regex.test(req.body.zblock)){ - getvalidity(req.body.zblock,res); + if (regex.test(zblock)){ + getvalidity(zblock,res); } else { res.send({error:"Invalid data"}); } diff --git a/api/routes/announceZChain/index.js b/api/routes/announceZChain/index.js index 092b6a9..91ac5b9 100644 --- a/api/routes/announceZChain/index.js +++ b/api/routes/announceZChain/index.js @@ -36,10 +36,11 @@ const getNSvalidity = require('../../validators/ZchainValidator') module.exports = (req, res) => { console.log(req); - if ( (req.body.zchain) && req.body.zchain.length === 62 ){//&& req.body.block_signature.length === 46){ + if ( (req.body.zchain) && typeof req.body.zchain === "string" && req.body.zchain.length === 62 ){ + let zchain = req.body.zchain; regex= /k51qzi5uqu5d[A-Za-z0-9]{50}/ - if (regex.test(req.body.zchain)){ // && regex.test(req.body.block_signature)){ - getNSvalidity(req.body.zchain,res); + if (regex.test(zchain)){ + getNSvalidity(zchain,res); } else { res.send({error:"Invalid data"}); } diff --git a/api/routes/getInnerIPFSContent/index.js b/api/routes/getInnerIPFSContent/index.js index e17d038..b3a05cb 100644 --- a/api/routes/getInnerIPFSContent/index.js +++ b/api/routes/getInnerIPFSContent/index.js @@ -15,13 +15,14 @@ function fetchZblock(zblock, res){ }; module.exports = (req, res) => { console.log(req.query) - if ( (req.query.ipfs) && req.query.ipfs.length === 46 ){ + if ( (req.query.ipfs) && typeof req.query.ipfs === "string" && req.query.ipfs.length === 46 ){ + let ipfs = req.query.ipfs; regex= /Qm[A-Za-z0-9]{44}/; - if (regex.test(req.query.ipfs)){ - if (req.query.ipfs === "QmbFMke1KXqnYyBBWxB74N4c5SBnJMVAiMNRcGu6x1AwQH" ){ + if (regex.test(ipfs)){ + if (ipfs === "QmbFMke1KXqnYyBBWxB74N4c5SBnJMVAiMNRcGu6x1AwQH" ){ res.send({error:"Genesis block"}); } else { - fetchZblock(req.query.ipfs,res); + fetchZblock(ipfs,res); } } else { res.send({error:"Invalid data: regexp failed to pass"}); |