Skip to content

Commit 6dd0aab

Browse files
authored
Revert obfuscation logic (#52)
This will not work since we need the s3 object key to trigger an action for the callback
1 parent b3bc420 commit 6dd0aab

File tree

2 files changed

+1
-55
lines changed

2 files changed

+1
-55
lines changed

lib/s3-handler.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ const CONFIG = require('./config').CONFIG;
55
const utils = require('./utils');
66
const scanii = require('./client');
77
const pkg = require('../package.json');
8-
const crypto = require('crypto');
98

109

1110
/**
@@ -54,13 +53,11 @@ exports.handler = async (event, context, callback) => {
5453
// signing request
5554
const signature = utils.generateSignature(bucket, key);
5655
console.log('using signature ' + signature);
57-
const sha1sum = crypto.createHash('sha1');
5856

59-
// we obfuscate the object key since it can contain sensitive information we don't want stored:
6057
const metadata = {
6158
"signature": signature,
6259
"bucket": bucket,
63-
"key-sha1": sha1sum.update(key).digest('hex')
60+
"key": key
6461
};
6562

6663
const submitResult = await scaniiClient.fetch(url, CONFIG.CALLBACK_URL, metadata);

tests/s3-handler.js

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -181,56 +181,5 @@ describe('S3 handler tests', () => {
181181
assert(result.body.includes("bucket not present"));
182182
});
183183
});
184-
it('should obfuscate the object key', async () => {
185-
nock('https://api.scanii.com')
186-
.post('/v2.1/files/fetch')
187-
.reply(202, Buffer.from("{\"id\":\"12356789\"}"), {"Location": "https://api.scanii.com/v2.1/files/1234"});
188-
189-
const spy = sinon.spy(scanii.ScaniiClient.prototype, 'fetch');
190-
191-
await handler({
192-
"Records": [
193-
{
194-
"eventVersion": "2.0",
195-
"eventSource": "aws:s3",
196-
"awsRegion": "us-west-2",
197-
"eventTime": "2015-10-01T23:28:54.280Z",
198-
"eventName": "ObjectCreated:Put",
199-
"userIdentity": {
200-
"principalId": "AWS:principal"
201-
},
202-
"requestParameters": {
203-
"sourceIPAddress": "98.167.155.191"
204-
},
205-
"responseElements": {
206-
"x-amz-request-id": "EEC943B096DE3DF9",
207-
"x-amz-id-2": "W/myEjyXFBsOA6N0byxW0tOxMA4m1fmv9KAVcovvG0nD9W1s5aX5+Wx61tlCop8LbZAw1Nz0mnc="
208-
},
209-
"s3": {
210-
"s3SchemaVersion": "1.0",
211-
"configurationId": "948c2c1a-a028-4564-93fc-76cea7622633",
212-
"bucket": {
213-
"name": "scanii-mu",
214-
"ownerIdentity": {
215-
"principalId": "principal"
216-
},
217-
"arn": "arn:aws:s3:::scanii-mu"
218-
},
219-
"object": {
220-
"key": "Screen+Shot+2016-01-19+at+7.24.37+PM.png",
221-
"size": 519,
222-
"eTag": "aa1e5c8a6a07217c25f55aa8e96ea37a",
223-
"sequencer": "00560DC1B62F962FCD"
224-
}
225-
}
226-
}
227-
]
228-
}, {}, () => {
229-
"use strict";
230-
assert(spy.calledOnce)
231-
assert((spy.getCall(0).args[2]['key-sha1'] === '8fd1943cbc9bf22f0b7f64aef9015f6494b81846'))
232-
assert((spy.getCall(0).args[2]['key'] === undefined))
233-
});
234-
});
235184
});
236185

0 commit comments

Comments
 (0)