Article 71KVW CodeSOD: Invalid Route and Invalid Route

CodeSOD: Invalid Route and Invalid Route

by
Remy Porter
from The Daily WTF on (#71KVW)

Someone wanted to make sure that invalid routes logged an error in their Go web application. Artem found this when looking at production code.

if (requestUriPath != "/config:system") && (requestUriPath != "/config:system/ntp") && (requestUriPath != "/config:system/ntp/servers") && (requestUriPath != "/config:system/ntp/servers/server") && (requestUriPath != "/config:system/ntp/servers/server/config") && (requestUriPath != "/config:system/ntp/servers/server/config/address") && (requestUriPath != "/config:system/ntp/servers/server/config/key-id") && (requestUriPath != "/config:system/ntp/servers/server/config/minpoll") && (requestUriPath != "/config:system/ntp/servers/server/config/maxpoll") && (requestUriPath != "/config:system/ntp/servers/server/config/version") && (requestUriPath != "/config:system/ntp/servers/server/state") && (requestUriPath != "/config:system/ntp/servers/server/state/address") && (requestUriPath != "/config:system/ntp/servers/server/state/key-id") && (requestUriPath != "/config:system/ntp/servers/server/state/minpoll") && (requestUriPath != "/config:system/ntp/servers/server/state/maxpoll") && (requestUriPath != "/config:system/ntp/servers/server/state/version") { log.Info("ProcessGetNtpServer: no return of ntp server state for ", requestUriPath) return nil}

The most disturbing part of this, for Artem, isn't that someone wrote this code and pushed it to production. It's that, according to git blame, two people wrote this code, because the first developer didn't include all the cases.

For the record, the application does have an actual router module, which can trigger logging on invalid routes.

proget-icon.png [Advertisement] Keep the plebs out of prod. Restrict NuGet feed privileges with ProGet. Learn more.
External Content
Source RSS or Atom Feed
Feed Location http://syndication.thedailywtf.com/TheDailyWtf
Feed Title The Daily WTF
Feed Link http://thedailywtf.com/
Reply 0 comments