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

Поделиться
HTML-код
  • Опубликовано: 27 янв 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!

  • @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!

  • @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

  • @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

  • @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.

  • @zacharyrice8547
    @zacharyrice8547 7 месяцев назад

    Thanks for featuring my tool! Great video!

  • @coffee-is-power
    @coffee-is-power 5 месяцев назад +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.

  • @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!

  • @shubhamarya1918
    @shubhamarya1918 7 месяцев назад

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

  • @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

  • @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!

  • @AlvaroOByrne
    @AlvaroOByrne 7 месяцев назад +16

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

  • @FlorianWendelborn
    @FlorianWendelborn 7 месяцев назад +16

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

    • @dreamsofcode
      @dreamsofcode  7 месяцев назад +3

      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.

  • @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....

  • @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)?

  • @xk0nsid
    @xk0nsid 7 месяцев назад +2

    At 2:55 "Dingus Dev ", hilarious 🤣

  • @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. 😁

  • @thomasrichards8055
    @thomasrichards8055 7 месяцев назад +1

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

  • @yjefecustom
    @yjefecustom 7 месяцев назад

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

  • @rumble_bird
    @rumble_bird 5 месяцев назад

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

  • @VinitKhandagle
    @VinitKhandagle 6 месяцев назад

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

  • @Windeycastle
    @Windeycastle 7 месяцев назад

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

  • @Majiy00
    @Majiy00 7 месяцев назад +3

    Great video as usual!

  • @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!

  • @conaticus
    @conaticus 7 месяцев назад +1

    Awesome tool!

  • @MohammadLsk
    @MohammadLsk 7 месяцев назад

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

  • @devinsonalvarez7111
    @devinsonalvarez7111 7 месяцев назад +1

    A video about Gitleaks would be very useful

  • @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!

  • @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

  • @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.

  • @KevinNitro
    @KevinNitro 7 месяцев назад

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

  • @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

  • @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 месяцев назад

    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.

  • @almuaz
    @almuaz 7 месяцев назад

    more 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

  • @dog4ik
    @dog4ik 7 месяцев назад +1

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

  • @_baco
    @_baco 7 месяцев назад

    video on GitLeaks, pls!

  • @akam9919
    @akam9919 7 месяцев назад

    Cool mug.

  • @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

  • @erictrinque6513
    @erictrinque6513 7 месяцев назад

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

  • @bopon4090
    @bopon4090 7 месяцев назад

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

  • @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

  • @TheKennyWorld
    @TheKennyWorld 3 месяца назад

    Never hardcode a secret, simple as that.

  • @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.

  • @daphenomenalz4100
    @daphenomenalz4100 7 месяцев назад

    My Solution used to be: Delete the Repository :D

  • @Rubricube
    @Rubricube 7 месяцев назад

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

  • @marliechiller
    @marliechiller 7 месяцев назад

    I thought you had moved to nixOS?

  • @Kaelthas93
    @Kaelthas93 7 месяцев назад

    Just change passwords or revoke tokens asap.

  • @fahimferdous1641
    @fahimferdous1641 7 месяцев назад

    Can't relate. I have commitment issues.

  • @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.

  • @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) ;)