• dan@upvote.au
    link
    fedilink
    arrow-up
    12
    ·
    edit-2
    4 months ago

    At my workplace, we use the string @nocommit to designate code that shouldn’t be checked in. Usually in a comment:

    // @nocommit temporary for testing
    apiKey = 'blah';
    // apiKey = getKeyFromKeychain(); 
    

    but it can be anywhere in the file.

    There’s a lint rule that looks for @nocommit in all modified files. It shows a lint error in dev and in our code review / build system, and commits that contain @nocommit anywhere are completely blocked from being merged.

    (the code in the lint rule does something like "@no"+"commit" to avoid triggering itself)

  • carrylex@lemmy.worldOP
    link
    fedilink
    arrow-up
    9
    ·
    edit-2
    4 months ago

    I also personally ask myself how a PyPI Admin & Director of Infrastructure can miss out on so many basic coding and security relevant aspects:

    • Hardcoding credentials and not using dedicated secret files, environment variable or other secret stores
    • For any source that you compile you have to assume that - in one way or another - it ends up in the final artifact - Apparently this was not fully understood (“.pyc files containing the compiled bytecode weren’t considered”)
    • Not using a isolated build process e.g. a CI with an isolated VM or a container - This will inevitable lead to “works on my machine” scenarios
    • Needing the built artifact (containerimage) only locally but pushing it into a publicly available registry
    • Using a access token that has full admin permissions for everything, despite only requiring it to bypass rate limits
    • Apparently using a single access token for everything
      • When you use Git locally and want to push to GitHub you need an access token. The fact that article says “the one and only GitHub access token related to my account” likely indicates that this token was at least also used for this
    • One of the takeaways of the article says “set aggressive expiration dates for API tokens” - This won’t help much if you don’t understand how to handle them properly in the first place. An attacker can still use them before they expire or simply extract updated tokens from newer artifacts.

    On the other hand what went well:

    • When this was reported it was reacted upon within a few minutes
    • Some of my above points of criticism now appear to be taken into account (“Takeaways”)
    • dan@upvote.au
      link
      fedilink
      arrow-up
      4
      ·
      4 months ago

      This will inevitable lead to “works on my machine” scenarios

      Isn’t this why Docker exists? It’s “works on my machine”-as-a-service.

    • bleistift2@sopuli.xyz
      link
      fedilink
      English
      arrow-up
      4
      ·
      4 months ago

      This will inevitable lead to “works on my machine” scenarios

      Isn’t that what Python is all about?

    • Jayjader@jlai.lu
      link
      fedilink
      English
      arrow-up
      1
      ·
      4 months ago

      When you use Git locally and want to push to GitHub you need an access token.

      I don’t understand; I can push to GitHub using https creds or an ssh key without creating access tokens.

  • ArbitraryValue@sh.itjust.works
    link
    fedilink
    English
    arrow-up
    5
    arrow-down
    1
    ·
    edit-2
    4 months ago

    On the contrary, one can commit or compile credentials quite simply… Maybe Boromir isn’t the right person to ask.

    • carrylex@lemmy.worldOP
      link
      fedilink
      arrow-up
      3
      ·
      edit-2
      4 months ago

      Well from my personal PoV there are a few problems with that

      1. You can’t detect all credentials reliably, they could be encoded in base64 for example
      2. I think it’s kind of okay to commit credentials and configuration used for the local dev environment (and ONLY the local one). E.g. when you require some infrastructure like a database inside a container for your app. Not every dev wants to manually set a few dozen configuration entries when they quickly want to checkout and run the app
      • bleistift2@sopuli.xyz
        link
        fedilink
        English
        arrow-up
        4
        ·
        4 months ago

        You can’t detect all credentials reliably,

        Easy. You check in the password file first. Then you can check if the codebase contains any entry on the blacklist.

        Wait…

        • pfm@scribe.disroot.org
          link
          fedilink
          arrow-up
          4
          ·
          4 months ago

          You were so close! The right solution is of course training an AI model that detects credentials and rejects commits that contain them!

  • MHanak@lemmy.world
    link
    fedilink
    arrow-up
    1
    ·
    4 months ago

    This reminds me of that one time when i pushed with my github token as my username (dw i revoked it)

  • katy ✨@lemmy.blahaj.zone
    link
    fedilink
    arrow-up
    0
    ·
    4 months ago

    don’t commit credentials; split them up and place each part in a different place in the code and use code comments as a treasure map and make them work for it.