
Product
Introducing Tier 1 Reachability: Precision CVE Triage for Enterprise Teams
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
github.com/pbreedt/fingerprintjs
A take-home assignment for FingerprintJS.
This project takes two files as input:
The aim it to maximize the transaction value that is being processed in a given time.
First get the source code by cloning the repository from GitHub:
git clone https://github.com/pbreedt/fingerprintjs.git
...and change into the newly created directory.
Then, either build the app:
go build
...or run it straight from source code:
go run . 1000
./fingerprintjs timeLimit [latency file] [transactions file]
timeLimit - number of total time allowed for processing
latency file - path to the latency JSON file (optional: default to ./input/api_latencies.json)
transactions file - path to the transactions CSV file (optional: default to ./input/transactions.csv)
The question that was posted was:
What is the max USD value that can be processed in 50ms, 60ms, 90ms, 1000ms?
My findings are as follows:
Time frame (ms) | Total Value | New Total | Actual ms |
---|---|---|---|
50 | 3637.98 | 4139.43 | (50) |
60 | 4362.01 | 4624.86 | (56) |
90 | 6870.48 | 6972.29 | (90) |
1000 | 35471.81 | 35471.81 | (1000) |
The algorithm
The basic principle is to calculate the 'value per second' for each transaction. This is, the USD value that will be processed for every 1s spend processing the particular transaction.
Next, I sort all the transactions according to the 'value per second' values, with the highest amounts taking preference if any two transactions have the same 'value per second'.
IMPROVEMENT:
Keep track of the time difference between processing time and total available time. Try and fill this time a little bit better.
General code
I tried to stay as close as possible to the originally provided function signatures, thus keeping the same input and return parameters.
Various 'debug' output lines have been commented out, but left in the code.
Some unit tests are included to check for predictable results for controlled input.
Thank you for the opportunity, I had fun doing this assignment!
Written by @pbreedt
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.