At my new job we use veracode to scan for vulnerabilities, including npm packages that are children of packages we use.
those seem a little tricky... I think the options are:
1. tell veracode to ignore it IF its dev dependency/internal tool only
2. upgrade the parent package(s) and hope it pulls a more recent version
3. use { "overrides" : "foo":"1.0.0" } (new since 2021 NPM v8.3.0)
everything is a little fraught but that last one seems the most promising to me.
(via Stack Overflow What is the role of the package-lock.json? )
Thursday, January 30, 2025
npm note
Tuesday, January 21, 2025
surveying eslint-disables across a code base
An architect was mentioning some counts of eslint-disables in our code base, and I wanted to take a closer look.
(I know different devs have different intuitions about the criticality of some of these rules: I know for me, if there's a trade off between "concise, more readable code that keeps attention to what's actually new" vs "well-enforced lint standards and rigorously enforced strong typing at every level that MIGHT help turn a runtime error into a buildtime problem", I lean towards the former.)
I started by recursive grepping for those lines, and putting them into a .txt file so future steps would be faster:
grep -r "eslint-disable" | grep -v node_modules/ > ~/raw.txt
I then used CoPilot to come up with a node.js script to break up the lines and do counts by subproject in the monorepo:)
const fs = require('fs');
const readline = require('readline');
// Create a read stream for raw.txt
const fileStream = fs.createReadStream('raw.txt');
// Create an interface to read the file line by line
const rl = readline.createInterface({
input: fileStream,
crlfDelay: Infinity
});
// Initialize the counts and totalCounts objects
const counts = {};
const totalCounts = {};
// Process each line
rl.on('line', (line) => {
// Split the line on whitespace
const sections = line.split(/\s+/);
const regex = /\.\/([^\/]+\/[^\/]+)\//;
const match = sections[0].match(regex);
if (!match) {
console.log(`NO MATCH FOR ${line}\n`);
return;
}
const appOrLib = match[1];
const offset = sections.findIndex(section => section.startsWith('eslint-disable'));
if (offset === -1) {
console.log(`NO MATCH FOR ${line}\n`);
} else {
// Join the remaining parts on " ", ignoring "*/"
const remainingParts = sections.slice(offset + 1).filter(part => part !== '*/');
const joinedParts = remainingParts.join(' ');
// Split each remaining part on "," and treat them separately
const finalParts = joinedParts.split(',').map(part => part.trim());
// Initialize the appOrLib object if it doesn't exist
if (!counts[appOrLib]) {
counts[appOrLib] = {};
totalCounts[appOrLib] = 0;
}
finalParts.forEach(part => {
const key = part || '[EMPTY]';
if (!counts[appOrLib][key]) {
counts[appOrLib][key] = 0;
}
counts[appOrLib][key]++;
totalCounts[appOrLib]++;
});
}
});
// Print the counts object when done
rl.on('close', () => {
for (const appOrLib in counts) {
console.log(`${appOrLib}: ${totalCounts[appOrLib]}`);
const sortedKeys = Object.keys(counts[appOrLib]).sort((a, b) => counts[appOrLib][b] - counts[appOrLib][a]);
sortedKeys.forEach(key => {
console.log(`\t${key}: ${counts[appOrLib][key]}`);
});
}
});
Saturday, January 4, 2025
Thursday, January 2, 2025
thumbs way up
So in FB Messenger, they recently changed the "send message" button - I believe that previously it was inactive until you typed some message content. Now it's a "thumbs up" button when the message body is empty, which sends a big thumbs up (btw, isn't that a rude gesture in some cultures? I was just googling to see if FB uses anything different elsewhere...)
So I noticed this on accident, when I see I had sent a big thumbs up between 2 of my own messages... (I quote "The Tao of Programming": "A program should follow the 'Law of Least Astonishment'. What is this law? It is simply that the program should always respond to the user in the way that astonishes him least.")
So, on the one hand, I could see that an easy general "OK" response is potentially useful, and a little easier to get to here than the usual "reaction" picker for previous messages. On the other hand... it seems weird to just make that the default message - especially to ones own messages. When you accidentally send one against your own message, it seems weirdly insecure or self-aggrandizing.
I wonder if they considered changing the "just send a thumbs up" function to activate only after the other person has written something back? That seems like a more useful scenario. But I guess would make the UI even more chaotic and unpredictable.
Thursday, December 26, 2024
whither redux? wither redux?
State of JS 2024 - The one thing I noticed about earlier renditions continues - weirdly silent on Redux, unless I'm not looking in the right place. Which is an older tool to be sure (it gives strong 2019 vibes, having been largely supplanted by useContext hooks) but two separate gigs I had in 2024 leaned on it heavily.
spaghetti, lasagna, onions
Back when I was your age, spaghetti code was the curse of the industry. Random gotos pointing anywhere. Branching into the middle of subroutines, or out.Then came lasagna apps. Layer upon layer of abstraction so deep nobody knew how it really worked -- if it did. Before you could dig down to the meat you had to scrape aside tons of moldy cheese.Now we have onion corporations. No one really does anything. They just contract with someone else to do it. And if you peel away that shell (tearfully) you find another contact handing off responsibility but skimming some of the dollars.It's turtles all the way down! Recursion FTW!
Monday, December 16, 2024
buildless evergreen
How One Programmer Broke the Internet By Deleting a Tiny Piece of Code - an article on the history that led to the trivial "left-pad" module being removed and causing all those problems by the removal a while back. Obviously raising the question, how much is too much when it comes to depending on modules and additional libraries to do all the heavy lifting?
I'm getting better at framing the divide between my work for Enterprise, and my personal project work. That rift of technologies used has grown wider over the years, though my personal project stuff - having to take on the full stack and the complete UX/UI experience - is still a huge boon to what I bring to the table for "real jobs"
Two buzzwords for one-person-shop, long term side project works that don't apply to most enterprise efforts: "buildless" and "evergreen". Sticking with tech that is likely to stay well-supported, you minimize dependencies on third parties. For me, that means - HTML/CSS/JS that the browser supports natively (browsers are truly impressive in advancing in power at a stately pace while maintaining brilliant backwards compatibility), often it means static HTML or PHP - while some people scoff, sticking with core PHP allows me to keep just one business relationship for deploying my code and maintaining my legacy sites, and the scripting paradigm PHP uses - a clean start every time - is very amenable to thinking in terms of functional programming, despite the ugliness of its APIs.
Again, Enterprise usually finds it better to invest in good toolkits and libraries and build systems, they can take on the cost of hiring people to make a code base an ongoing concern, and it's generally worth the complexity to make sure developers are meeting the company's needs by answering the basic problems in idiomatic ways. But when I want to write code that just works for my needs reliably over years and is usually pretty easy to edit when it some functionality needs to be added, the rules of "KISS" really apply.
