review-service-baseline
Advanced tools
Comparing version 0.0.6 to 0.0.7
@@ -0,1 +1,2 @@ | ||
'use strict'; | ||
var Generator = require('yeoman-generator'); | ||
@@ -16,9 +17,4 @@ | ||
const copies = { | ||
'ingest/functions.yml': 'tmp/ingest.func.tmp', | ||
'validation/functions.yml': 'tmp/validation.func.tmp', | ||
'moderation/functions.yml': 'tmp/moderation.func.tmp', | ||
'view/functions.yml': 'tmp/view.func.tmp', | ||
'examples/**/*': this.options.codeDir, | ||
'serverless.yml': 'serverless.yml', | ||
'../package.import.json': 'package.json' | ||
'../package.import.json': 'package.json' | ||
}; | ||
@@ -35,4 +31,4 @@ | ||
fileOps(templateCopy, copies); | ||
fileOps(templateCopy, copies); | ||
} | ||
}; |
'use strict'; | ||
module.exports = { | ||
validation: require('./src/common/app'), | ||
ingest: require('./src/common/app'), | ||
moderation: require('./src/common/app'), | ||
view: require('./src/common/app'), | ||
pipe: require('./src/common/app') | ||
}; |
{ | ||
"name": "review-service-baseline", | ||
"description": "", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"scripts": {}, | ||
@@ -6,0 +6,0 @@ "author": "KB.T", |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -21,3 +21,52 @@ 'use strict'; | ||
update(key, kvp, table, callback) { | ||
const timestamp = new Date().getTime(); | ||
let params = {AttributeUpdates: {}}; | ||
params.TableName = table; | ||
params.Key = { id : { S: key} }; | ||
for(var k in kvp) { | ||
let value = kvp[k]; | ||
let Value = {} , type = ''; | ||
if(Array.isArray(value)) { | ||
type = "S"; | ||
let typeCheck = value.pop(0); | ||
value.push(typeCheck); | ||
console.log("typecheck : " + (typeof typeCheck)); | ||
if(typeof typeCheck === "number") { | ||
type = "N" + type; | ||
} else if(typeof typeCheck === "string") { | ||
type = "S" + type; | ||
} | ||
} else if(typeof value === "number") { | ||
type = "N" + type; | ||
} else if(typeof value === "string") { | ||
type = "S" + type; | ||
} else if(typeof value === "boolean") { | ||
type = "BOOL"; | ||
} else if(typeof value === "object") { | ||
type = "M" | ||
} | ||
Value[type] = value; | ||
params.AttributeUpdates[k] = { Value, Action: "PUT" } | ||
} | ||
params.ReturnValues = "NONE"; | ||
console.log(JSON.stringify(params)); | ||
this.db.updateItem(params, callback); | ||
} | ||
selectByFieldExists(field, table, callback) { | ||
let params = { | ||
"FilterExpression": `attribute_exists(${field})`, | ||
"TableName": table | ||
}; | ||
db.scan(params, callback); | ||
} | ||
} | ||
module.exports = DB; |
@@ -5,3 +5,2 @@ const AWS = require('aws-sdk'); | ||
const File = require('./file'); | ||
const doc = require('dynamodb-doc'); | ||
@@ -12,3 +11,3 @@ module.exports = function() { | ||
queue: new Queue(new AWS.SNS()), | ||
db: new DB(new doc.DynamoDB()), | ||
db: new DB(new AWS.DynamoDB()), | ||
file: new File(new AWS.S3()), | ||
@@ -15,0 +14,0 @@ stats: {} |
'use strict'; | ||
let validation = require('review-service-baseline').validation; | ||
const headers = { headers: { 'Content-Type': 'application/json' } }; | ||
let resource; | ||
exports.handler = validation | ||
let validation = require('review-service-baseline').pipe; | ||
module.exports.handler = validation | ||
.init(function(rs, next) { | ||
this.resource = rs; | ||
const configpath = require('path').join(__dirname, 'webpurify.config.json'); | ||
const config = JSON.parse(require('fs').readFileSync(configpath, 'utf8')); | ||
const WebPurify = require('webpurify'); | ||
const wp = new WebPurify(config.key); | ||
const validator = new Validator({"client":wp, "config":config}, require('./schema_validation')); | ||
next({ | ||
resource = new rs(); | ||
next({ validator: validator, config: config }); | ||
}).input(function(event, next, params) { | ||
}); | ||
}) | ||
.input(function(data, next, params) { | ||
params.validator.validate(event); | ||
let payload = JSON.parse(event.body).payload; | ||
let pfields = config.verifyFields.filter((field) => { | ||
return payload[field]; | ||
}); | ||
let config = process.env.EXAMLE_CONFIG || 'no config defined in env'; | ||
let data = { 0: true, 1: false }; | ||
if(pfields.length) { | ||
let err, resp = {status: 'OK'}, msg = {payload:payload} | ||
params.validator.purify(pfields.map((f) => payload[f]).join()) | ||
.fetch((profanity) => { | ||
if(profanity.length !==0) { | ||
next('when-profanity-found', { | ||
err: {reason:'Profanity'}, resp: {status:'NOK', profanity: profanity} | ||
}); | ||
} else { | ||
next('when-no-profanity', { err: null, resp:{status: 'OK'}}); | ||
} | ||
}); | ||
}, (err) => { throw err; }); | ||
if(data[Math.floor(Math.random() * 2)]) { | ||
next('when-no-profanity',{data:{status:'OK', text:'No profanity found', config:config}}); | ||
} else { | ||
next('when-profanity-found',{data:{status:'NOK', text:'Profanity found', config:config}}); | ||
} | ||
}).output('when-no-profanity',function(params, cb) { | ||
notifier.notify(JSON.stringify(msg), process.env.SNS_TOPIC, (err, data) => { | ||
console.log('sns callback'); | ||
console.log(err); | ||
console.log(data); | ||
}); | ||
callback(null, { statusCode:'200', body: '{}', headers }); | ||
}).output('when-profanity-found',function(params, cb) { | ||
callback(null, { statusCode:'400', body: JSON.stringify(params.resp), headers }); | ||
}).error(function(e) { | ||
console.log('err from project : ' + e ); | ||
}).output('when-profanity-found',function(params, resp) { | ||
resp.callback(null, { statusCode:'200', body: JSON.stringify(params.data), | ||
headers: { 'Content-Type': 'application/json' } }); | ||
}).output('when-no-profanity',function(params, resp) { | ||
resp.callback(null, { statusCode:'200', body: JSON.stringify(params.data), | ||
headers: { 'Content-Type': 'application/json' } }); | ||
}).done(); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12
41656
40
1312
2