Skip to content

Commit

Permalink
Merge pull request #27 from FlowFuse/zj-ip-open
Browse files Browse the repository at this point in the history
collection: Don't SHA the Request IP
  • Loading branch information
knolleary authored Jul 1, 2024
2 parents de57f42 + 6faddb8 commit 85f69ec
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
5 changes: 1 addition & 4 deletions src/app.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
const { Client } = require("pg");
const crypto = require('crypto')
const sha256 = value => crypto.createHash('sha256').update(value).digest().toString('base64')


// NOTE: any changes to required/optional props will require the database table
// to be updated first. DO NOT DEPLOY changes to these lists without having
Expand Down Expand Up @@ -96,7 +93,7 @@ exports.handler = async (event, context) => {
})

item.ip = (event.requestContext && event.requestContext.http)
? sha256(event.requestContext.http.sourceIp)
? event.requestContext.http.sourceIp
: 'unknown'

optionalProperties.forEach(key => {
Expand Down
2 changes: 1 addition & 1 deletion test/app_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ describe('Ping Collector', async function () {
assert.equal(ping.instanceId, 'test-instance')
assert.equal(ping['os.type'], 'linux')
assert.ok(ping.ip)
assert.notEqual(ping.ip, '192.168.0.1')
assert.equal(ping.ip, '192.168.0.1')
// Check createdAt is within last 500ms
assert.ok(Date.now() - ping.created_at.getTime() < 500)

Expand Down

0 comments on commit 85f69ec

Please sign in to comment.