So, you've committed a secret, what next?

Поділитися
Вставка
  • Опубліковано 2 лют 2025

КОМЕНТАРІ • 124

  • @focksen7797
    @focksen7797 7 місяців тому +149

    We recently had an email service token leak, which resulted in 1.2 mil scam emails being sent from the company noreply mail, so this is very important advice!

  • @spr3ez
    @spr3ez 7 місяців тому +98

    Just always use commit in combination with push -f to annoy your comrades

    • @AScribblingTurtle
      @AScribblingTurtle 7 місяців тому +14

      bonus points if you automate it to happen in save.

    • @FlorianWendelborn
      @FlorianWendelborn 7 місяців тому +24

      git add -A && git commit --amend --author "Senior Developer" --no-edit --no-verify && git push -f

    • @makuru.42
      @makuru.42 7 місяців тому +3

      @@FlorianWendelborn now put it in an funny alias and it's perfect!

    • @whoman0385
      @whoman0385 7 місяців тому +1

      wait you guys dont do that?

  • @dandogamer
    @dandogamer 7 місяців тому +40

    Tbh if i find a leak with this tool im just gonna rotate the secret rather than mess around with git

    • @dreamsofcode
      @dreamsofcode  7 місяців тому +5

      Even if it's only on your local machine?

    • @IsaacShoebottom
      @IsaacShoebottom 7 місяців тому +6

      @@dreamsofcode probably less time than messing with git. if you have to move to a secret file anyways, when you move the key, just rotate it then

    • @dreamsofcode
      @dreamsofcode  7 місяців тому +4

      ​@@IsaacShoebottom I think if that works for you then go for it! In my case I much prefer to do a quick git reset which also prevents any false positives in the future.

    • @dandogamer
      @dandogamer 7 місяців тому +1

      @@dreamsofcode I think I would do the following:
      1. Identify existing leaks and change secrets
      2. Integrate the tool as part of my workflow thereby preventing any new leaks
      IF a new leak somehow occurs and is a false positive you can update the baseline of the tool so it wont look any further back

    • @andyvirus2300
      @andyvirus2300 7 місяців тому +1

      @@IsaacShoebottom you probably need to learn how to use git, because this is faster, cleaner and safer

  • @orterves
    @orterves 7 місяців тому +19

    8:12 force pushing to a remote is fine if you own the branch. Don't force push shared branches like main. Do force push branches that only you have committed to, it's a very good way to clean up and reorganize a branch pre-merge.
    If you feel uncomfortable knowing when it's ok to force push and when it's not, study and practice git, it's worth it.

    • @dreamsofcode
      @dreamsofcode  7 місяців тому +5

      Agreed! Your own branch is fine (I believe I mentioned that), but never main (unless it's your own and you know what you're doing). I was definitely erring on the side of caution with this message as I didn't want to encourage people to force push without knowing when it is useful.

    • @orterves
      @orterves 7 місяців тому +2

      @dreamsofcode I think you did too - just hoping to add a little extra clarification for people new to git who are a bit too scared of using it effectively (in my experience)

    • @dreamsofcode
      @dreamsofcode  7 місяців тому +2

      ​@@orterves gotcha! And you're correct as well. I actually have another video planned looking more at force push!

  • @zacharyrice8547
    @zacharyrice8547 7 місяців тому

    Thanks for featuring my tool! Great video!

  • @coffee-is-power
    @coffee-is-power 6 місяців тому +1

    3:00 This is MUUUCH easier with lazygit, you just go to the leaking commit, press enter, find the file, press enter again, select the line of the secret, press ctrl+p to open custom patch options menu and then press d or select Remove patch from original commit and you're done

  • @elizabethharasymiw7025
    @elizabethharasymiw7025 7 місяців тому

    Thanks for thoroughly explaining how to resolve these issues as I bet this guidance will help give people the solutions they need to get these issues approved to fix.

  • @v2tacos322
    @v2tacos322 7 місяців тому +2

    Your spinning warning symbol graphic at 8:07 seems to rotate around an axis aligned with its face rather than its midpoint, and has a weird smear on the frame its parallel to camera.

  • @shubhamarya1918
    @shubhamarya1918 7 місяців тому

    This was really informative Thank you. I just recently gave an interview and I was presented with this EXACT question.

  • @Possseidon
    @Possseidon 7 місяців тому +65

    I'd go with `git commit --amend` if you really just need to fixup the last commit. No need to temporarily undo it completely with `git reset --soft HEAD~1`.
    Also, one should use the "dotenvy" crate for Rust; "dotenv" is no longer maintained.

    • @dreamsofcode
      @dreamsofcode  7 місяців тому +24

      Ahh shoot! I did not realize it was no longer maintained! Thanks for letting me know!
      amend is also a good option as well!

    • @dawidgrzeskow987
      @dawidgrzeskow987 7 місяців тому +1

      Thanks you magic anime girl of wisdom

  • @nickgramru
    @nickgramru 7 місяців тому +3

    I liked your video. Thanks a lot for doing them. What about the git filter-repo and other tools that might edit only the needed parts of the commits history?

    • @dreamsofcode
      @dreamsofcode  7 місяців тому +3

      git-filter repo is pretty dope from what I've seen! I've never used it personally however as I tend to stick with just the basic git commands. Perhaps that's a good excuse to do a video and check it out!

  • @roganl
    @roganl 7 місяців тому +11

    Well Done Tris. I am still not used to seeing your mug in these videos. Clearly articulated, demonstrated, and now to get lazy devs to follow suit....

  • @thomasrichards8055
    @thomasrichards8055 7 місяців тому +1

    How do you feel about the “git commit --fixup”/“git rebase --autosquash --interactive” combo?

  • @rumble_bird
    @rumble_bird 6 місяців тому

    this is more of a git tutorial on interactive rebasing for me, extremely educational stuff

  • @AlvaroOByrne
    @AlvaroOByrne 7 місяців тому +16

    Please make a video going deeper into this , gitleaks, thanks in advance

  • @VinitKhandagle
    @VinitKhandagle 7 місяців тому

    the terminal status bar is amazing also the neovim colorscheme. May I ask what are you using to get this done.

  • @codeman99-dev
    @codeman99-dev 7 місяців тому +2

    A note on `gitleaks`! Please think about how the tool does detection and react accordingly. Do not blindly run the tool on code you do not personally have distribute rights to. Definitely perform a full audit of the tool when running against mission critical code.

    • @dreamsofcode
      @dreamsofcode  7 місяців тому

      Good advice on all code, if you're extra paranoid, run it with your network disabled!

  • @yjefecustom
    @yjefecustom 7 місяців тому

    would have been nice if I had this information about 2 months ago :) thanks for pushing this out though!

  • @xk0nsid
    @xk0nsid 7 місяців тому +2

    At 2:55 "Dingus Dev ", hilarious 🤣

  • @FlorianWendelborn
    @FlorianWendelborn 7 місяців тому +16

    Step 1 after encountering a leak should be to invalidate the credentials.

    • @dreamsofcode
      @dreamsofcode  7 місяців тому +4

      If they're on a remote repo, as I mentioned in the video I would instead rather do an investigation otherwise you might be encouraging unnecessary downtime.

  • @EmileNani
    @EmileNani 7 місяців тому +1

    Hey man,
    Mind sharing what you used to make the animations?

    • @dreamsofcode
      @dreamsofcode  7 місяців тому

      I make them myself using After Effects!

    • @EmileNani
      @EmileNani 7 місяців тому

      @@dreamsofcodeVery cool. Thanks

  • @bijayaprasadkuikel5162
    @bijayaprasadkuikel5162 7 місяців тому

    Superb content as always. I am waiting for a full microservices course from you. 😁

  • @trueberryless
    @trueberryless 7 місяців тому +5

    I'd love to see videos in the future which go deeper into especially those things said in the last minute (Pre commits generally, other secret solutions and generally secret managers) ❤

    • @dreamsofcode
      @dreamsofcode  7 місяців тому +2

      Absolutely! I'll make sure to add them to my backlog

  • @tracyrreed
    @tracyrreed 4 місяці тому +1

    Damn you, Dingus!

  • @indignocat
    @indignocat 6 місяців тому

    does `git gc --aggressive´ do anything in this case (to gc the previous, compromised commits)?

  • @Luclecool123
    @Luclecool123 7 місяців тому +2

    One of my biggest fear is to commit my home address by accident, and not even noticing 😅

    • @dreamsofcode
      @dreamsofcode  7 місяців тому +2

      I accidentally doxxed myself on stream one time so I know this fear!

  • @Windeycastle
    @Windeycastle 7 місяців тому

    That was an interesting video!
    I'd love to watch more useful git-topics if you have more.

  • @MohammadLsk
    @MohammadLsk 7 місяців тому

    Thank you for the excellent video. Also, using git filter-repo is a good way to remove a file from history.

  • @berndeckenfels
    @berndeckenfels 7 місяців тому +8

    The leaked secrets should always be considered compromised

    • @eli1882
      @eli1882 7 місяців тому

      That's the most stupid thing I have heard this week

    • @dreamsofcode
      @dreamsofcode  7 місяців тому

      Even if they haven't left your own machine?

    • @berndeckenfels
      @berndeckenfels 7 місяців тому

      @@dreamsofcode I would generally recommend to roll over secrets when in doubt, it should be done regularly anyway and not at all an operational hassle. If people don’t ask, I won’t recommend it, so if they feel confident then let them be the decider. On the other hand I also feel very bad about .env files or environment variables on my own machine

    • @ImperiumLibertas
      @ImperiumLibertas 7 місяців тому

      ​@@dreamsofcode if they haven't left your machine they are not leaked 🙃

    • @dreamsofcode
      @dreamsofcode  7 місяців тому

      @@ImperiumLibertas Yep.

  • @Majiy00
    @Majiy00 7 місяців тому +3

    Great video as usual!

  • @conaticus
    @conaticus 7 місяців тому +1

    Awesome tool!

  • @KevinNitro
    @KevinNitro 7 місяців тому

    Are... are you using... Arch with Hyprland?
    👉👈

  • @_baco
    @_baco 7 місяців тому

    Although I share the belief that good hygiene is better than tooling the git commit around with pre-commit, in a not-so-big team that is already difficult to enforce. And code-reviews could be used in a better way.

  • @devinsonalvarez7111
    @devinsonalvarez7111 7 місяців тому +1

    A video about Gitleaks would be very useful

  • @bijayaprasadkuikel5162
    @bijayaprasadkuikel5162 7 місяців тому

    I think you must make one video about setting up neovim for go developers. I am diehard Goland fan but I would like to try neovim.

  • @inononeeee
    @inononeeee 7 місяців тому +1

    the must watch video

  • @GameDesignerJDG
    @GameDesignerJDG 7 місяців тому +1

    Hey! Love your content! I'm at work right now, so can't watch the video, but the title really bugs me for a really important reason. Anyone who's searching for this video when they really need it will never be able to find it. If someone pushes an API key to origin/main and they need to find out how to fix it, they'll never be able to find this particular video. I don't mind clickbait most of the time, but I strongly urge you to make the title more searchable since this topic, in particular, can be a make-or-break seconds-on-the-clock job-on-the-line emergency for someone or several someones.

    • @dreamsofcode
      @dreamsofcode  7 місяців тому +1

      Hey! Thanks for the feedback and the great suggestion! I will definitely change this title once the algorithm has done it's thing as I 100% agree with you. I usually do this for more searchable content once the recommendation process has finished as this also helps to get higher views, which will help with searchability as well. Thank you again for the great suggestion

    • @GameDesignerJDG
      @GameDesignerJDG 7 місяців тому

      @@dreamsofcode That's great!

  • @almuaz
    @almuaz 7 місяців тому

    more on gitleaks pls

  • @uncenter_
    @uncenter_ 7 місяців тому

    doesn't github automatically detect this for many common types of secrets (and revokes them)?

    • @dreamsofcode
      @dreamsofcode  7 місяців тому

      Someone mentioned this but I've never seen this happen, (mainly because I don't commit them). But the cache password did still exist in the private repo.

    • @berndeckenfels
      @berndeckenfels 7 місяців тому

      In my experience it does not work well, I even opened a bug for a sample file with a false positive and a false negative within 3 lines of script ,)

  • @_baco
    @_baco 7 місяців тому

    video on GitLeaks, pls!

  • @erikvanraalte4557
    @erikvanraalte4557 7 місяців тому

    Why are you not a fan of pre-commit hooks? I find them rather useful as a guard against user mistakes (secrets, but also linting etc)

    • @dreamsofcode
      @dreamsofcode  7 місяців тому +1

      It's a completely personal opinion (I can see the benefits) but I don't like the idea of becoming dependent on them and having too much trust in the process. That's totally a me issue though

    • @ImperiumLibertas
      @ImperiumLibertas 7 місяців тому +1

      ​@@dreamsofcodetrust but verify. The verify part being a pre commit hook

  • @TheKennyWorld
    @TheKennyWorld 3 місяці тому

    Never hardcode a secret, simple as that.

  • @Rignchen
    @Rignchen 7 місяців тому

    4:10 Hey, actuelly you didn't remove from the git history, you just created à commit with the same parent as the HEAD but we can still find it

    • @dreamsofcode
      @dreamsofcode  7 місяців тому

      Correct, I believe I mention this. The commit will be garbage collected eventually, but the idea is that you don't push these commits up which becomes a much larger problem.

    • @Rignchen
      @Rignchen 7 місяців тому

      I still haven't seen the end of the video so idk

  • @akam9919
    @akam9919 7 місяців тому

    Cool mug.

  • @erictrinque6513
    @erictrinque6513 7 місяців тому

    Gitleaks opportunity missed. GitLeeks... it reeks of leeks. Writes itself

  • @zhytedark2859
    @zhytedark2859 7 місяців тому

    Is it also a big problem if it's in private repo ?

    • @dreamsofcode
      @dreamsofcode  7 місяців тому +2

      I think it depends on how many people have access, but really I'd try to avoid hardcoding as much as possible.

    • @zhytedark2859
      @zhytedark2859 7 місяців тому

      @@dreamsofcode Yeah I get it. My problem is to keep my exported key in a my dots file for full reset

    • @dreamsofcode
      @dreamsofcode  7 місяців тому +2

      ​@@zhytedark2859 I should do a video on my dotfiles, but I actually use password store, a Gpg public key, and a yubikey to help with secrets in mine. That way all I need to do is plug in the yubikey and it'll work

    • @thimvana8030
      @thimvana8030 7 місяців тому +1

      @@dreamsofcode Would love to see a video on this!

    • @Windeycastle
      @Windeycastle 7 місяців тому

      ​@@thimvana8030I thought he already had a video on that topic? I am using the same password manager due to that video, I believe

  • @dog4ik
    @dog4ik 7 місяців тому +1

    rust dotenv crate is no longer maintained, prefer dotenvy instead.

  • @daphenomenalz4100
    @daphenomenalz4100 7 місяців тому

    My Solution used to be: Delete the Repository :D

  • @niikolajj9333
    @niikolajj9333 7 місяців тому

    Loved the crime joke!

    • @dreamsofcode
      @dreamsofcode  7 місяців тому +1

      Thank you! I went a lot harder in the earlier edits but decide to tone it down a little haha

  • @elifry1478
    @elifry1478 7 місяців тому

    I see even well-versed devs make mistakes. Sometimes, as with crypto, this causes the loss of thousands or millions of dollars. Pre-commit hooks in sensitive situations (many such cases) are needed, as a last resort.

  • @bopon4090
    @bopon4090 7 місяців тому

    If i accidentally push password or secret key i'll change password/secret key and its enough.

  • @marliechiller
    @marliechiller 7 місяців тому

    I thought you had moved to nixOS?

  • @Rubricube
    @Rubricube 7 місяців тому

    Please make a video that goes more in depth about leaks.

  • @JoeyJooste
    @JoeyJooste 7 місяців тому

    I love your videos, but this video seriously missed the mark in terms of accuracy, if someone actually does this in a real environment they will not be safe. Step 1 should be invalidating the current secret, Step 2 should be then figuring out how to replace it without leaking the new key.
    The millisecond you push a key to a public repo, it gets logged by many git logger services, so no matter what you do, it’s comprised. That’s why you must first delete, figure out later.

    • @1998marijn1998
      @1998marijn1998 7 місяців тому

      Did you watch the full video? The first half is for locally committed secrets.

  • @Kaelthas93
    @Kaelthas93 7 місяців тому

    Just change passwords or revoke tokens asap.

  • @fahimferdous1641
    @fahimferdous1641 7 місяців тому

    Can't relate. I have commitment issues.

  • @loserdavictor
    @loserdavictor 7 місяців тому

    sorry i ruthlessly disliked due to the terrible joke in the beginning "dont commit crime", but liked bcz it got better in the later part of the video :)

  • @albert21994
    @albert21994 7 місяців тому

    FAST WATCHER SQUAD

  • @THEMithrandir09
    @THEMithrandir09 7 місяців тому

    Using such a tool in this way is useless for a dev and cleaning up the history is utterly unnecessary. Just invalidate all relevant secrets if it happened and move on.
    Where tools like this really shine for us devs is running it as a pre-commit hook, because then it isn't too late yet.

    • @dreamsofcode
      @dreamsofcode  7 місяців тому +1

      I think it's worth cleaning up your history before pushing.
      I also mention the pre-commit hook at the end, (although I do think having better hygiene is more important).

    • @THEMithrandir09
      @THEMithrandir09 7 місяців тому

      @@dreamsofcode Oh yea, for sure, if you haven't pushed anything yet, nothing did happen "yet", as you do here. But having to force push the trunk will make a bunch of your team members very unhappy. But since this is one of these outliers where developers can do permanent "damage" in a software system, putting the guardrails upfront in the video (the pre-commit part) and then showing what the tool does and how to work with it would've been better. I didn't even make it to the pre-commit part before leaving my comment - and for that I am sorry.

  • @greob
    @greob 7 місяців тому

    Thanks for the video. Small suggestion: reduce the amount of bass in your voice recordings, it's a bit distracting and unpleasant (maybe it's just me though) ;)