14
15 Comments

How to protect code?

I have a question on github code policy. Generally in all the environments like vercel, render, railway etc. We have auto deploy code from github repository. How do we ensure we protect the code as its public? I mean someone can fork the repo and do their own thing.

posted to Icon for group Developers
Developers
on January 14, 2023
  1. 5

    Hey akshaymattoo,

    Specifically for Vercel, you can use a private repository with auto deploy. I'm not too familiar with the other environments but I imagine they can also work with a private repository.

    I deployed my Newsletter site (https://generatedpress.com) from a private repo through Vercel. It has auto-deploy enabled so whenever I push to the main branch, it still works even though it's private.

    I suggest trying out the environments with a private repo!

    1. 1

      Thank you that helps. I will try that.

  2. 3

    First, make sure your repository is private.

    Moreover, make sure that no configuration's included in your code. Both have to be decoupled: you store your configuration away from your repository codebase. You can generally follow the 12 factors of best practices for modern apps.
    Have a look: https://12factor.net/config

    Finally, you may add a license to your project that restricts commercialization and non-allowed usage. Hope this helps.

    1. 2

      Hey @saidaitmbarek, very good points. Would you recommend a license that fits well for solo builders? I don’t use any currently, just protect my code by private repo and decoupled secrets from code.

      1. 1

        I am doing the same as @mateusmsouza. Please suggest steps and what license to apply on the code.

        1. 1

          It really depends on your project and what software you're using. Assuming you use GPLv3 libraries, you must yourself release your software under the GPLv3 licence.
          The most restrictive creative commons licence is the "CC-BY-NC-ND" which restricts commercialization of your software.

  3. 2

    Just as a heads up, if you have already pushed your code into a public repo AND your code contained any keys/secrets then they have been copied by bad actors.

    Reset all keys/secrets that you had in that repo and make sure you do not store those details in a repository. Ideally they are injected at build time.

  4. 2

    Keep your repo private. Almost every hosting provider such as vercel and netlify allow you to connect your private repo and auto deploy it.

    1. 1

      I am using render I will try that. Thank you for the response.

  5. 1

    Tldr: you can't do it. JavaScript code needs to be available to the client. You can only make it harder and more annoying.

    For node code (eg. Electron) you can use bytecode build step that will convert your code into semi-native V8 bytecode version of your code. This will already make 95% of rookie hackers go away.

    You can also use this if performance hit is not w problem: https://github.com/javascript-obfuscator/javascript-obfuscator . It'll make people reverse engineering it life's a lot harder

  6. 1

    Keep your repo private. Almost each and every web hosting issuer such as vercel and netlify enable you to join your personal repo and auto install it.
    http://garagedoorrepairglenallen.net/garage-door-spring-repair/

  7. 1

    This are some excelent tools to showcase your work and protect your code as well:

    www.protegerhtml.com/en

    www.protegerjavascript.com/en

    www.protegerphp.com/en

    www.ofuscarphp.com/en

    and

    www.protegerfotos.con.gt/en

    We have developed all those tools at www.sabro.net/en which you can test for free directly from your browser, hope it helps

    Cheers!!!

    1. 1

      Thank you will surely take a look.

  8. 1

    to protect code, i would highly recommend making a repository private. I would then add some gates on github that for example would require your authorization before code would be merged into your project's master branch.

    1. 1

      Thank you very much. Will do it.

Trending on Indie Hackers
From Ideas to a Content Factory: The Rise of SuperMaker AI User Avatar 27 comments Why Early-Stage Founders Should Consider Skipping Prior Art Searches for Their Patent Applications User Avatar 21 comments Codenhack Beta — Full Access + Referral User Avatar 17 comments I built eSIMKitStore — helping travelers stay online with instant QR-based eSIMs 🌍 User Avatar 15 comments Building something...? User Avatar 12 comments Do Patents Really Help Startups Raise Funding? Evidence from the U.S. and Europe User Avatar 11 comments