Skip to main content

CodeSOD: A Secure Item

2 months 2 weeks ago

Kirill writes:

I've worked in this small company for a year, and on a daily basis I've come across things that make my eyes sink back into their sockets in fear, but mostly I've been too busy fixing them to post anything. It being my last day however, here's a classic

We'll take this one in parts. First, every element of the UI the user can navigate to is marked with an enum, defined thus:

enum UiItem { SectionA, SectionB, SectionC,...SectionG }

These names are not anonymized, so already I hate it. But it's the next enum that starts my skin crawling:

enum SecurityUiItem { SectionA = UiItem.SectionA, SectionB = UiItem.SectionB, ... SectionG = UiItem.SectionG }

A SecurityUiItem is a different type, but the values are identical to UiItem.

These enums are used when trying to evaluate role-based permissions for access, and that code looks like this:

if ((currentAccess.ContainsKey(SecurityUiItem.SectionA) && currentAccess[SecurityUiItem.SectionA] != AccessLevel.NoAccess)) return UiItem.SectionA; else if (!currentAccess.ContainsKey(SecurityUiItem.SectionB) || (currentAccess.ContainsKey(SecurityUiItem.SectionB) && currentAccess[SecurityUiItem.SectionB] != AccessLevel.NoAccess)) return UiItem.SectionB; else if (!currentAccess.ContainsKey(SecurityUiItem.SectionC) || (currentAccess.ContainsKey(SecurityUiItem.SectionC) && currentAccess[SecurityUiItem.SectionC] != AccessLevel.NoAccess)) return UiItem.SectionC; ..... else if (!currentAccess.ContainsKey(SecurityUiItem.SectionG) || (currentAccess.ContainsKey(SecurityUiItem.SectionG) && currentAccess[SecurityUiItem.SectionG] != AccessLevel.NoAccess)) return UiItem.SectionG; else return UiItem.Unknown;

Honestly, I don't hate the idea of having one data type representing the actual UI objects and a separate data type which represents permissions, and having a function which can map between these two things. But this is a perfect example of a good idea executed poorly.

I also have to wonder about the fall-through pattern. If I have access to SectionA, I only seem to get SectionA out of this function. Are these permissions hierarchical? I have no idea, but I suspect there's a WTF underpinning this whole thing.

Congratulations on Kirill's last day.

[Advertisement] Picking up NuGet is easy. Getting good at it takes time. Download our guide to learn the best practice of NuGet for the Enterprise.
Remy Porter

Blackwell Is The Fastest Ramping Compute Engine In Nvidia’s History

2 months 2 weeks ago

With the months-long blip in manufacturing that delayed the “Blackwell” B100 and B200 generations of GPUs in the rear view mirror and nerves more calm about the potential threat that the techniques used in the AI models of Chinese startup DeepSeek better understood, Nvidia’s final quarter of its fiscal 2025 and its projections for continuing sequential growth in fiscal 2026 will bring joy to Wall Street. …

Blackwell Is The Fastest Ramping Compute Engine In Nvidia’s History was written by Timothy Prickett Morgan at The Next Platform.

Timothy Prickett Morgan

Tokyo Is Turning To a 4-Day Workweek To Shed 'World's Oldest Population' Title

2 months 2 weeks ago
An anonymous reader quotes a report from Fortune: Starting in April, the Tokyo Metropolitan government, one of the country's largest employers, is set to allow its employees to work only four days a week. It is also adding a new "childcare partial leave" policy, which will allow some employees to work two fewer hours per day. The goal is to help employees who are parents balance childcare and work, said Tokyo Gov. Yuriko Koike. "We will continue to review work styles flexibly to ensure that women do not have to sacrifice their careers due to life events such as childbirth or child-rearing," Koike said in a speech during the Tokyo Metropolitan Assembly's regular session, the Japan Times reported. Moving to a four-day workweek could help address some of the core issues associated with Japan's heavy work culture, which can especially weigh on working women. The gap between men and women when it comes to housework is one of the largest among OECD countries, with women in Japan engaging in five times more unpaid work, such as childcare and elder care, than men, according to the International Monetary Fund. More than half of women who had fewer children than they would have preferred said they had fewer children because of the increased housework that another child would bring, according to the IMF. In some cases, moving to a four-day workweek has been shown to improve housework equity. Men reported spending 22% more time on childcare and 23% more time on housework during a four-day workweek trial conducted across six countries by 4 Day Week Global, which advocates for the issue. It would take a major societal change for the four-day workweek to catch on more broadly, but years of experiments have shown that working one day less a week improves employee productivity and well-being, said Peter Miscovich, the global future of work leader at real estate services company JLL. "The upside from all of that has been less stress, less burnout, better rest, better sleep, less cost to the employee, higher levels of focus and concentration during the working hours, and in some cases, greater commitment to the organization as a result," Miscovich told Fortune.

Read more of this story at Slashdot.

BeauHD