this post was submitted on 21 Mar 2025
676 points (100.0% liked)

Programmer Humor

21988 readers
1427 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
 

Original post: hachyderm.io (Mastodon)

top 50 comments
sorted by: hot top controversial new old
[–] [email protected] 11 points 6 days ago

var true = false;

var false = true;

[–] [email protected] 188 points 1 week ago* (last edited 1 week ago) (2 children)

So we need to be careful with upper- and lowercase. Meanwhile the docs: > settiings

[–] [email protected] 105 points 1 week ago (2 children)

Yes, the settiings are different than the settings. You also need to be careful with those.

[–] [email protected] 36 points 1 week ago

had to use a different spelliings at backend and frontend, otherwise it wouldn't work.

[–] [email protected] 11 points 1 week ago* (last edited 1 week ago) (3 children)

no, settings = settings but settings != Settings, as we all know.

load more comments (3 replies)
load more comments (1 replies)
[–] [email protected] 91 points 1 week ago (5 children)

Is the backend Python and the frontend JavaScript? Because then that would happen and just be normal, because Boolean true is True in python.

[–] [email protected] 138 points 1 week ago (4 children)

Probably, but if you're interpreting user inputs as raw code, you've got much much worse problems going on, lol.

[–] [email protected] 37 points 1 week ago (1 children)

[...]&register=import os; os.system("sudo rm -rf /"); return True

[–] [email protected] 17 points 1 week ago

Hey, that's my username too. Or it was going to be, while the site was still up.

What a coincidence!

I guess I'll wait for the site to come back, and see if it's still available...

[–] [email protected] 21 points 1 week ago (1 children)

It's the settiings file... It's probably supposed to only be written by the system admin.

[–] [email protected] 10 points 1 week ago* (last edited 1 week ago) (2 children)

A good place to put persistent malware. That's why when using docker images always mount as ro if at all possible.

[–] [email protected] 10 points 1 week ago (1 children)

It’s you can modify the settings file you sure as hell can put the malware anywhere you want

[–] [email protected] 2 points 4 days ago* (last edited 4 days ago)

It’s you can modify the settings file you sure as hell can put the malware anywhere you want

True. (But in case it amuses you or others reading along:) But a code settings file still carries it's own special risk, as an executable file, in a predictable place, that gets run regularly.

An executable settings file is particularly nice for the attacker, as it's a great place to ensure that any injected code gets executed without much effort.

In particular, if an attacker can force a reboot, they know the settings file will get read reasonably early during the start-up process.

So a settings file that's written in code can be useful for an attacker who can write to the disk (like through a poorly secured upload prompt), but doesn't have full shell access yet.

They will typically upload a reverse shell, and use a line added to settings to ensure the reverse shell gets executed and starts listening for connections.

Edit (because it may also amuse anyone reading along): The same attack can be accomplished with a JSON or YAML settings file, but it relies on the JSON or YAML interpreter having a known critical security flaw. Thankfully most of them don't usually have one, most of the time, if they're kept up to date.

load more comments (1 replies)
[–] [email protected] 8 points 1 week ago (1 children)

Given the warning about capitalization, the best possible case is that they're using ast.literal_eval() rather than throwing untrusted input into eval().

Err, I guess they might be comparing strings to 'True' and are choosing to be really strict about capitalization for some reason.

[–] [email protected] 12 points 1 week ago

Yeah. Maybe .to_lower() is really expensive in their environment, lol.

load more comments (1 replies)
[–] [email protected] 22 points 1 week ago (3 children)

I curse the sadist who decided True should be uppercase in Python

load more comments (3 replies)
[–] [email protected] 16 points 1 week ago (5 children)

Can't they just convert a "true" input to backend to uppercase

[–] [email protected] 28 points 1 week ago

Yep they should use a config file format like JSON or TOML or YAML or what have you, and then decode that into python objects. Using an actual programming language for config is dumb as hell IMO. (inb4 pissed off suckless fans)

load more comments (4 replies)
[–] [email protected] 8 points 1 week ago

Searching for the phrase, documentation matches for Taiga so maybe you're right!

load more comments (1 replies)
[–] [email protected] 87 points 1 week ago (9 children)

Could be worse. At least it's documented

load more comments (9 replies)
[–] [email protected] 32 points 1 week ago (2 children)

The cherry on top is that they didn't even spell settings correctly.

[–] [email protected] 25 points 1 week ago

settiings is spelled differently on the backend

load more comments (1 replies)
[–] [email protected] 20 points 1 week ago (2 children)

Glorious. I remember some hilarious nonsense in an API where the devs I worked with hadn't known they could just use boolean in JSON and had badly implemented it through strings, but this... This is amazing!

[–] [email protected] 1 points 6 days ago

A system I work with gives all keys a string value of "Not_set" when the key is intended to be unset. The team decided to put this in because of a connection with a different, legacy system, whose developers (somehow) could not distinguish between a key being missing or being present but with a null value. So now every team that integrates with this system has to deal with these unset values.

Of course, it's up to individual developers to never forget to set a key to "Not_Set". Also, they forgot to standardise capitalisation and such so there are all sorts of variations "NOT_SET", "Not_set", "NotSet", etc. floating around the API responses. Also null is still a possible value you need to handle as well, though what it means is context dependent (usually it means someone fucked up).

[–] [email protected] 8 points 1 week ago

At my last job we had a lot of old code, and our supposedly smartest framework people couldn't be bothered learning front end properly. So there was a mix of methods for passing values to the front end, but nobody seemed to think of just passing JSON and parsing it into a single source of truth. There was so much digging for data in hidden columns of nested HTML tables, and you never knew if booleans would be "true", "TRUE", "1", or "Y" strings.

Never mind having to unformat currency strings to check the value then format them back to strings after updating values.

I fixed this stuff when I could, but it was half baked into the custom framework.

[–] [email protected] 18 points 1 week ago (1 children)

Implying Hell is frontend.... yeah, actually, that tracks.

load more comments (1 replies)
[–] [email protected] 16 points 1 week ago (1 children)

And you all complained when in C we used 1 and 0...

[–] [email protected] 7 points 6 days ago (1 children)
[–] [email protected] 4 points 6 days ago (1 children)

Akcshually we use 0 and "not equal 0", since "not 0" would be 0xFF..FF, and (at least gcc) gives back a 1 for a true expression. No idea about the spec, probably undefined...

[–] [email protected] 2 points 6 days ago

Damn you for correcting me correctly! :D

[–] [email protected] 14 points 1 week ago (2 children)

What happened to the good old 1

[–] [email protected] 21 points 1 week ago

Backend: 1

Frontend: ¹

load more comments (1 replies)
[–] [email protected] 13 points 1 week ago (2 children)

Hear me out, what about using JSON to store the configuration in the Python backend?

[–] [email protected] 9 points 1 week ago

You need to use as many different formats as possible, otherwise you look unprofessional

load more comments (1 replies)
[–] [email protected] 12 points 1 week ago (2 children)

I’ve always hated case sensitivity. I know that at an ASCII level “variable” != “Variable” but is there really a reason to have a distinction between them?

[–] [email protected] 22 points 1 week ago (1 children)

You stated the reason yourself. Those are different values and matching in a case-insensitive manner is more work under the hood.

[–] [email protected] 8 points 1 week ago (3 children)

We do plenty of stuff for human consumption. Computers work for us, not the other way around. Insensitivity should be the default. It’s okay to give options. I’m not saying take that away.

load more comments (3 replies)
[–] [email protected] 20 points 1 week ago

You are thinking it's easy because you only think of e == E, but I'll let you look up collation and accents and, you know, Unicode and let you think about it.

There is nothing trivial about case sensitivity, except in trivial cases.

[–] [email protected] 10 points 1 week ago

That makes me think, perhaps, you might be able to set it to exec("stuff") or True...

[–] [email protected] 8 points 1 week ago* (last edited 1 week ago) (3 children)
load more comments (3 replies)
[–] [email protected] 7 points 1 week ago

Cap in the back, low-key up front. Got it.

load more comments
view more: next ›