Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Plexorank is a python implementation of a lexicographical ranking system.
A perfect back-end pair for a front-end user based sorting preference, such as drag and drop operations, Plexorank was inspired by Jira's Lexorank.
When a user drags an item before or after another item and expects that order to be maintained, we'll need some sort of storage mechanism to ensure persistent order, even after the user logs out. We'll also need something performant enough to allow a user to drag and drop rapidly without triggering loads of back-end computation.
Enter Plexorank - when a user manually alters the order of a list or table, a new rank must be calculated. Using alphabetical rather than numerical sorting, we're able to perform only a single operation on the entity that was moved. To do this, when an item is moved in an order, the front end needs to send three pieces of information: the ids of the previous_item
, the current_item
, and the next_item
. Previous and next may be ignored if an item is moved to the top or bottom of a list. We send ids rather than ranks themselves to ensure eventual consistency.
On the back end, the ids of the previous_item
and next_item
will be used to fetch those corresponding ranks and calculate the mean rank between the two.
previous_item
is null
or unsupplied, we'll decrement the rank from the next_item
next_item
is null
or unsupplied, we'll increment the rank from the previous_item
previous_item
and next_item
are null
or unsupplied, we'll assign an initial rank, as this is the only item in the list.Plexorank uses a base-26 cipher:
Plexorank uses what I call "n-tacking" to solve conflicts. If a new rank conflicts with another rank in the same subset of entities, simply addind the letter "n" to the end of the new rank solves the problem in two wonderful ways:
aaaa
and aaab
, we simpy take the upper rank aaaa
and tack on an "n" to get aaaan
, which sits squarely between aaaa
and aaab
.aaaa
and aaaan
and 12 slots between aaaan
and aaab
before we'll need to tack on another "n"Yeah, pretty well. Let's say you've allocated the rank
column of your database to allow for strings up to 255 characters. That means you have 26^255 ranks available to you. If you need more or start to hit a "hot spot", you can simply rebalance the table by reassigning initial ranks. This will maintain the order of the list while essentially "restarting" the ranking system with nice low-length ranks.
create_bulk_ranks
takes a single integer - the number of ranks you need - and returns a list of string ranks, evenly spaced from bbbbbb
to ffffff
.
create_mean_rank
takes two string ranks (e.g. "abgkskjhg"
and "ajdhfjhrt"
) and returns a new rank squarely in the middle (e.g. "afevywvmm"
)
increment_rank
takes a single string rank (e.g. "aacbd"
) and returns a new rank incremented by a single value of the "second" position of the rank (in this case, b -> c) (e.g. "aaccd"
)
"aaza"
returns "abaa"
decrement_rank
takes a single string rank (e.g. "aacbd"
) and returns a new rank decremented by a single value of the "second" position of the rank (in this case, b -> a) (e.g. "aacad"
)
"acaa"
returns "abza"
FAQs
A lexicographical ranking system for python
We found that plexorank demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.