• DB (unregistered)

    Frist frist.

  • bewbs (unregistered)

    second!

    . . . .not spam

  • Chronomium (unregistered)

    The worst part is probably all the variables defined at the start of the code, especially those commented out. Only two of them are actually used, while the rest imply that some sort of heavy-duty database punching was attempted at some point.

  • DB (unregistered)

    Anyway, I'm not a seasoned .NET programmer, but it's possible they were trying to avoid any potential issues with an empty or null return value.

  • M (unregistered) in reply to Chronomium
    Chronomium:
    The worst part is probably all the variables defined at the start of the code, especially those commented out. Only two of them are actually used, while the rest imply that some sort of heavy-duty database punching was attempted at some point.

    Maybe they tried putting all the connection strings in a database table?

    Not removing the obviously useless code is definitely a WTF. Also, who the heck is still using hungarian notation? sHere, sThere, sEverywhere.

  • (cs)

    Another WTF is how ASP.Net defaults breaks PCI compliance.

    Connection strings have usernames and passwords in them in plain text when usign them this way. Either encrypt them or do not use the config file to store them, have the config file point to something else that has them and that is encrypted.

    Another possible way of getting them is through some service call, or maybe not getting them at all, let the service call access the data instead of the Asp.net application. Of course then you have the config file for the service that needs to be cleaned, but that is easier to point to a resource that has encrypted data instead of that resource being accessable from your web server.

  • honnza (unregistered) in reply to M
    M:
    Chronomium:
    The worst part is probably all the variables defined at the start of the code, especially those commented out. Only two of them are actually used, while the rest imply that some sort of heavy-duty database punching was attempted at some point.

    Maybe they tried putting all the connection strings in a database table?

    Not removing the obviously useless code is definitely a WTF. Also, who the heck is still using hungarian notation? sHere, sThere, sEverywhere.

    $var for jQuery objects? Kinda useful in weakly typed languages with similar types.

  • (cs) in reply to KattMan
    KattMan:
    Another WTF is how ASP.Net defaults breaks PCI compliance.

    Connection strings have usernames and passwords in them in plain text when usign them this way. Either encrypt them or do not use the config file to store them, have the config file point to something else that has them and that is encrypted.

    Another possible way of getting them is through some service call, or maybe not getting them at all, let the service call access the data instead of the Asp.net application. Of course then you have the config file for the service that needs to be cleaned, but that is easier to point to a resource that has encrypted data instead of that resource being accessable from your web server.

    Read the chapter on "Integrated Security."

  • (cs) in reply to KattMan
    KattMan:
    Connection strings have usernames and passwords in them in plain text when usign them this way. Either encrypt them or do not use the config file to store them, have the config file point to something else that has them and that is encrypted.

    Well, you can encrypt them in the config file, so I assume "this way" refers to this (unused) part:

    sColumns = "DataLink, Platform, Login, Password, Server, Database"

    Encryption is less of a big deal if you're dealing with an intranet app, or if the login only has read access to data that you want to share with the general public anyway.

  • (cs) in reply to bewbs
    bewbs:
    not spam
    Let's agree to disagree on that.
  • HungarianProf (unregistered)

    The Real WTF is that they do not have a string variable called HitCount (or anything that begins with Hit ...)

  • anony-mouse (unregistered) in reply to KattMan
    KattMan:
    Another WTF is how ASP.Net defaults breaks PCI compliance.

    Connection strings have usernames and passwords in them in plain text when usign them this way. Either encrypt them or do not use the config file to store them, have the config file point to something else that has them and that is encrypted.

    Another possible way of getting them is through some service call, or maybe not getting them at all, let the service call access the data instead of the Asp.net application. Of course then you have the config file for the service that needs to be cleaned, but that is easier to point to a resource that has encrypted data instead of that resource being accessable from your web server.

    Haven't heard of Windows Authentication, eh? If you're using ASP.NET you're probably using MS SQL Server, in which the proper security model is to use Windows auth instead of a hard coded login/password.
  • Nagesh (unregistered)
    The major atrocity here is that instead of simply getting the connection string by key ('ConnectionString' in this case), they first look it up by position. This makes no sense. Later, if the lookup-by-position works, then they get it by key.
    Um, I'm not fluent in VB.NET, but I can't see any "look it up by position" in the code snippet here. What they are doing seems to be to ask if the key at position 0 is 'ConnectionString', and then look it up by key. In all other cases -- including when 'ConnectionString' is the key in some non-zero position -- then they pretend that whatever the key at position 0 is, is the right connection string to use!

    That's much more of a WTF than doing something that works but in a unnecessarily roundabout way.

  • (cs) in reply to Nagesh
    Nagesh:
    The major atrocity here is that instead of simply getting the connection string by key ('ConnectionString' in this case), they first look it up by position. This makes no sense. Later, if the lookup-by-position works, then they get it by key.
    Um, I'm not fluent in VB.NET, but I can't see any "look it up by position" in the code snippet here. What they are doing seems to be to ask if the key at position 0 is 'ConnectionString', and then look it up by key. In all other cases -- including when 'ConnectionString' is the key in some non-zero position -- then they pretend that whatever the key at position 0 is, is the right connection string to use!

    That's much more of a WTF than doing something that works but in a unnecessarily roundabout way.

    Did someone forget to switch sock-puppet names again?

  • Marc (unregistered) in reply to Nagesh

    I'm glad you said this, cause that's how I am reading it too.

  • Puzzles (unregistered) in reply to M
    M:
    Also, who the heck is still using hungarian notation? sHere, sThere, sEverywhere.
    Not only that, but only one of those three was actually declared as a string.

    "Dim x, y, z As String" creates z as a string but x and y as variants.

  • (cs) in reply to anony-mouse
    anony-mouse:
    Haven't heard of Windows Authentication, eh? If you're using ASP.NET you're probably using MS SQL Server, in which the proper security model is to use Windows auth instead of a hard coded login/password.

    Not always, I've had Informix databases sitting behind and ASP.Net app.

    I agree, the inetuser should be the one with access and use authentication, but not always easy with certian databases.

  • (cs)

    Some Manager probably said

    "The Key is the Connection"

    And it was.

  • (cs) in reply to KattMan
    KattMan:
    Another WTF is how ASP.Net defaults breaks PCI compliance.

    Connection strings have usernames and passwords in them in plain text when usign them this way. Either encrypt them or do not use the config file to store them, have the config file point to something else that has them and that is encrypted.

    Another possible way of getting them is through some service call, or maybe not getting them at all, let the service call access the data instead of the Asp.net application. Of course then you have the config file for the service that needs to be cleaned, but that is easier to point to a resource that has encrypted data instead of that resource being accessable from your web server.

    Or you can encrypt the data in your web.config file.

  • (cs) in reply to cdosrun
    cdosrun:
    KattMan:
    Another WTF is how ASP.Net defaults breaks PCI compliance.

    Connection strings have usernames and passwords in them in plain text when usign them this way. Either encrypt them or do not use the config file to store them, have the config file point to something else that has them and that is encrypted.

    Another possible way of getting them is through some service call, or maybe not getting them at all, let the service call access the data instead of the Asp.net application. Of course then you have the config file for the service that needs to be cleaned, but that is easier to point to a resource that has encrypted data instead of that resource being accessable from your web server.

    Or you can encrypt the data in your web.config file.

    Yes you could, but try managing that from an global perspective, any time a password changes (remember PCI requires this) you need to update all the web configs you have in your system.

    Or you could have one file that has this that all the web.configs point to and simply change that one file.

    Granted, if your company is small enough to only have one site or service then this isn't a problem.

  • M (unregistered) in reply to KattMan
    KattMan:
    anony-mouse:
    Haven't heard of Windows Authentication, eh? If you're using ASP.NET you're probably using MS SQL Server, in which the proper security model is to use Windows auth instead of a hard coded login/password.

    Not always, I've had Informix databases sitting behind and ASP.Net app.

    I agree, the inetuser should be the one with access and use authentication, but not always easy with certian databases.

    Agreed. A place I know uses asp.net backed by oracle everywhere. In fact, many of the separate oracle database servers were recently 'upgraded' to a single exadata server. Now all the apps get to share in the fun on those occasions when oracle flakes out, i.e. often.

  • (cs)

    This is a total WTF. They should have looked up a key by position that would tell them the position of the database connection key. That way, they could move the database key by changing the first key.

    As it is, the database key is stuck forever at position 0. Where's the configurability?

  • hangy (unregistered)
    sColumns = "DataLink, Platform, Login, Password, Server, Database"
    sTableName = "tblzApp"
    

    Aside from being out-of-context for this method - both variables are only being assigned to and are never read?!

  • Jeff (unregistered) in reply to KattMan
    KattMan:
    Another WTF is how ASP.Net defaults breaks PCI compliance.

    Connection strings have usernames and passwords in them in plain text when usign them this way. Either encrypt them or do not use the config file to store them, have the config file point to something else that has them and that is encrypted.

    But, to decrypt them, you need the key. Where do you get that? From another file? Shouldn't that be encrypted too?

  • Bradley (unregistered) in reply to Puzzles
    Puzzles:
    M:
    Also, who the heck is still using hungarian notation? sHere, sThere, sEverywhere.
    Not only that, but only one of those three was actually declared as a string.

    "Dim x, y, z As String" creates z as a string but x and y as variants.

    Not since vb6.

  • Wyrm (unregistered) in reply to Nagesh

    It's even worse than I thought at first. If the connection string is not the first configuration line, it doesn't even return the first configuration value but the first key. Someone really has messed this up big time.

  • (cs) in reply to Jeff
    Jeff:
    KattMan:
    Another WTF is how ASP.Net defaults breaks PCI compliance.

    Connection strings have usernames and passwords in them in plain text when usign them this way. Either encrypt them or do not use the config file to store them, have the config file point to something else that has them and that is encrypted.

    But, to decrypt them, you need the key. Where do you get that? From another file? Shouldn't that be encrypted too?
    DPAPI. It's secure against everyone except administrators or those with physical access to the box. Almost nothing can help you in those two cases.

  • (cs) in reply to KattMan
    KattMan:
    cdosrun:
    KattMan:
    Another WTF is how ASP.Net defaults breaks PCI compliance.

    Connection strings have usernames and passwords in them in plain text when usign them this way. Either encrypt them or do not use the config file to store them, have the config file point to something else that has them and that is encrypted.

    Another possible way of getting them is through some service call, or maybe not getting them at all, let the service call access the data instead of the Asp.net application. Of course then you have the config file for the service that needs to be cleaned, but that is easier to point to a resource that has encrypted data instead of that resource being accessable from your web server.

    Or you can encrypt the data in your web.config file.

    Yes you could, but try managing that from an global perspective, any time a password changes (remember PCI requires this) you need to update all the web configs you have in your system.

    Or you could have one file that has this that all the web.configs point to and simply change that one file.

    Granted, if your company is small enough to only have one site or service then this isn't a problem.

    Decrypting, changing, and re-encrypting is easy to script:

    Aspnet_regiis -pdf "connectionStrings" <<change password>> Aspnet_regiis -pef "connectionStrings"

    Also, creating a parent web.config that multiple applications inherit from is a built-in feature of ASP.Net, so you don't have to write customer code to create a pointer to a single configuration. The code is entirely unaware of the inheritance.

  • I ar the frist! (unregistered)

    PCI compliance? Who the hell care about that?!

  • Dirk (unregistered)

    Where's the WTF? They are simply making a mechanism to point at different dbs by config. The enterprise library does something similar by it's default connection string mechanism. Sure, they should have had a named key for the default connection string key, however, not a huge issue.

  • Dirk (unregistered) in reply to Dirk
    Dirk:
    Where's the WTF? They are simply making a mechanism to point at different dbs by config. The enterprise library does something similar by it's default connection string mechanism. Sure, they should have had a named key for the default connection string key, however, not a huge issue.
    Ummm, ignore this comment. Not enough coffee yet or I'm still high.
  • (cs) in reply to anony-mouse
    anony-mouse:
    Haven't heard of Windows Authentication, eh? If you're using ASP.NET you're probably using MS SQL Server, in which the proper security model is to use Windows auth instead of a hard coded login/password.

    Unless the web site is meant to be accessed from outside your network.

  • (cs)

    Too many people don't know that .net lets you encrypt connection strings, besides which, your IIS should be configured in such a way that httprequests to web.config are denied by default.

    Does anyone else take issue with the way the data access layer is called "DAL"? shit like that makes my blood boil, like calling your business layer "BLL" - what does that class do again? oh yeah, it logics your business layer, how silly of me.

  • Dave (unregistered) in reply to I ar the frist!
    I ar the frist!:
    PCI compliance? Who the hell care about that?!

    Well, since PCI compliance unambiguously guarantees impenetrable security, you simply implement PCI, then you don't need to think about security and best practices any more. It's a huge saving, and a great deal of peace of mind, for any company.

    The more you know.

  • AB (unregistered) in reply to KattMan
    KattMan:
    Another WTF is how ASP.Net defaults breaks PCI compliance.

    Connection strings have usernames and passwords in them in plain text when usign them this way. Either encrypt them or do not use the config file to store them, have the config file point to something else that has them and that is encrypted.

    Another possible way of getting them is through some service call, or maybe not getting them at all, let the service call access the data instead of the Asp.net application. Of course then you have the config file for the service that needs to be cleaned, but that is easier to point to a resource that has encrypted data instead of that resource being accessable from your web server.

    TRWTF. Idiots like you are what lead to code like the OP.

  • Hewes (unregistered) in reply to Dave
    Dave:
    I ar the frist!:
    PCI compliance? Who the hell care about that?!

    Well, since PCI compliance unambiguously guarantees impenetrable security, you simply implement PCI, then you don't need to think about security and best practices any more. It's a huge saving, and a great deal of peace of mind, for any company.

    The more you know.

    Wow...

    Just wow, seriously, you said this?

    PCI is more a minimum requirement for not being as holey as a leaky sieve.

    Dothing nothing but meeing the minimum requirements of PCI DSS means you qualify to call yourself more secure than than a firevault made of chocolate, nothing more.

  • Hmmmm (unregistered) in reply to Dirk
    Dirk:
    Ummm, ignore this comment. Not enough coffee yet or I'm still high.
    Probably both if I'm any judge...
  • Hmmmm (unregistered) in reply to Hewes
    Hewes:
    Wow...

    Just wow, seriously, you said this?

    You must be new here.

    -100 internets for falling for obvious troll...

  • (cs) in reply to HungarianProf
    HungarianProf:
    The Real WTF is that they do not have a string variable called HitCount (or anything that begins with Hit ...)
    in Hungarian notation would that be sHitCount?
  • Jeff (unregistered) in reply to Jaime
    Jaime:
    Jeff:
    KattMan:
    Another WTF is how ASP.Net defaults breaks PCI compliance.

    Connection strings have usernames and passwords in them in plain text when usign them this way. Either encrypt them or do not use the config file to store them, have the config file point to something else that has them and that is encrypted.

    But, to decrypt them, you need the key. Where do you get that? From another file? Shouldn't that be encrypted too?
    DPAPI. It's secure against everyone except administrators or those with physical access to the box. Almost nothing can help you in those two cases.
    Hey Jamie, are you a salesman? (Saleswoman?) Your answer surely makes me think so.

    1. Answer a technical question with a buzzword.

    2. Assurance that it "is secure" -- an unachievable state, but a nice marketing term.

    3. No discussion of how this magic might achieve its lofty promise.

  • Bridget (unregistered) in reply to Dave
    Dave:
    I ar the frist!:
    PCI compliance? Who the hell care about that?!

    Well, since PCI compliance unambiguously guarantees impenetrable security, you simply implement PCI, then you don't need to think about security and best practices any more. It's a huge saving, and a great deal of peace of mind, for any company.

    The more you know.

    We must work at the same place, because I swear I've heard that before in the past few months.

  • Todd Lewis (unregistered)

    TRWTF is not doing this in Perl. Then nobody would expect it to be right anyway, so no disappointment.

    [I actually like Perl. It's like python for people who aren't afraid of punctuation.]

  • Nagesh (unregistered) in reply to PedanticCurmudgeon
    PedanticCurmudgeon:
    Nagesh:
    Um, I'm not fluent in VB.NET, but I can't see any "look it up by position" in the code snippet here. What they are doing seems to be to ask if the key at position 0 is 'ConnectionString', and then look it up by key. In all other cases -- including when 'ConnectionString' is the key in some non-zero position -- then they pretend that whatever the key at position 0 is, is the right connection string to use!

    That's much more of a WTF than doing something that works but in a unnecessarily roundabout way.

    Did someone forget to switch sock-puppet names again?
    "Sock puppet"? It's only a sock puppet if a reasonable person could think the names denotes an actual person. Effectively, "Nagesh" is just the accepted spelling variant for "Anonymous" here.

  • radarbob (unregistered) in reply to Silfax
    Silfax:
    HungarianProf:
    The Real WTF is that they do not have a string variable called HitCount (or anything that begins with Hit ...)
    in Hungarian notation would that be sHitCount?
    +10 internets, Silfax.
  • Pedant (unregistered)

    Willing to hazard good money that all the commented out crap was an initial effort to store all their configuration in a database, including the connection strings.

    All was going well until, hang on, seem to be getting some deep recursion here...

  • (cs) in reply to Silfax
    Silfax:
    HungarianProf:
    The Real WTF is that they do not have a string variable called HitCount (or anything that begins with Hit ...)
    in Hungarian notation would that be sHitCount?
    Does anyone have a "That's the joke!" image I can borrow?
  • (cs) in reply to HungarianProf
    HungarianProf:
    The Real WTF is that they do not have a string variable called HitCount (or anything that begins with Hit ...)

    Oh come on! Get the joke right. "HitList".

  • (cs) in reply to bewbs
    bewbs:
    second!

    . . . .not spam

    What do you mean by "not spam"? It so very much is spam.

  • ¯\(°_o)/¯ I DUNNO LOL (unregistered) in reply to Hewes
    Hewes:
    PCI is more a minimum requirement for not being as holey as a leaky sieve.

    Dothing nothing but meeing the minimum requirements of PCI DSS means you qualify to call yourself more secure than than a firevault made of chocolate, nothing more.

    I'll have you know that my computer has FOUR of them PCI slots!

  • MikeD (unregistered) in reply to KattMan

    You don't have to have the user name and password in the connection string. Most places I worked that required PCI compliance used a trusted connection and has the app/service run with the active directory identity of a user that was setup with access to the database.

Leave a comment on “Disconnection String”

Log In or post as a guest

Replying to comment #:

« Return to Article