<p>There really is no way to take on your problem with git, which is to deny a developer with access to the code (required to work with it) the possibility to steal the code. This is because as soon as your developer has the code in a readable format (to program on it), he can do with it whatever he wants, anyways.</p>

<p>git-crypt has a totally different use, and is not related to your problem at all.</p>

<p>To solve your problem, there is basically only one possibility: lock the network in which the code resides down completely - make it so that there is no physical way to transfer the code to the outside. This could mean:</p>

<ul>
<li>No direct internet connection, obviously. </li>
<li>No http/https proxy either, no mail clients etc.</li>
<li>No way to add new devices to the network (unless through official ways). E.g., no unused network ports to plug anything in; no guest DHCP; MAC address filtering; no WIFI, smartphones; etc.</li>
<li>No way to plug an USB device or other transfer mechanism into any devices.</li>
</ul>

<p>This may sound harsh, but really is not. It could be as simple as keeping your code strictly within a set of VMs, accessed by something like Vmware Horizon or something like that, with cut&amp;paste and file transfer disabled, of course. Be nice to your developers and allow them to transfer stuff <em>into</em> the environment (their favourite editor, for example).</p>

<p>The measures so far do not require any physical changes, i.e. your developers still can work remotely or in their usual unsecure office. Obviously, they still can go to extreme measures (screenshots on their client PC...) to get specific parts of the code page-by-page.</p>

<p>To go a step further, in increasing severity (although we are going into James Bond territory here...): </p>

<ul>
<li>Strict policy with severe punishment. Setup a specific contract which each emplyee which contains clauses as harsh as the laws of your country allow.</li>
<li>Switching access to the limited network to a physical area in your office.</li>
<li>Security measures like locked doors accessible to only specific personnel, video cameras with 24/7 human supervision and so on. </li>
<li>2-factor access (either 2 persons required to checkout code, or at least a physical TAN generator or something along those lines).</li>
</ul>

<p>Note that in your case you want to make it hard for a thief who knows that he is doing something illegal and already has committed to doing a crime. He will not respect any "weak" protection (like rules/laws) anyways.</p>

CC BY-SA 3.0
2018-04-09T03:10:58.980Z
You forgot: "No phones" ;) No technical approach can be 100% effective against determined enough malicious intent: some people have a really good memory, others can understand really well what the code does. In either case the code or its equivalent can be reproduced outside the technical barriers.
Dan Cornilescu
CC BY-SA 3.0
2018-04-09T06:14:37.267Z
Absolutely, @DanCornilescu. I didn't want to stray too much into James Bond territory. ;)
AnoE
CC BY-SA 3.0
2018-04-09T20:20:14.477Z
Unless you can also control the remote access machines, there is no way to stop someone from screen shotting the code and running some OCR. Or in the worst case typing it out manually. Securing something that you also give access to is kind of pointless as it can all be gotten around.
jecxjo
CC BY-SA 3.0
2018-04-09T20:55:13.157Z
Yes, I mentioned that, @jecxjo. This answer is not so much about providing a solution to an ultra secure high-risk military software development complex, but to put into perspective why `git-crypt` is not the correct tool of choice...
AnoE
CC BY-SA 3.0
2018-04-08T18:50:08.373Z
2018-04-09T13:27:25.230Z
2018-04-09T13:27:25.230Z
AnoE
<p>I am using git and have the following problem:
In the company where I work you now want to protect the source code from theft.
So if for some reason a developer lets the source code of a project go along and sells it, for example.
To prevent this, I thought about it for a long time and came to the conclusion that encrypting the source code is the best choice. 
Like <a href="https://github.com/AGWA/git-crypt" rel="nofollow noreferrer">git-crypt</a> does, that's a very good idea.
Only with one mistake:
If I add a user's GPG key, he can decrypt all files, and the protection measure would be worthless.
The files of the developer should be decrypted locally and only remotely. (This way the developer does not always have to encrypt, push, decrypt the files)</p>

<p>I tried to re-program <a href="https://github.com/AGWA/git-crypt" rel="nofollow noreferrer">git-crypt</a> in Python (because of cross-platform) but then failed due to the git attributes/smudge, clean filter drivers.</p>

<p>Do you know a possibility or an application that takes up exactly my problem? </p>

CC BY-SA 3.0
2018-04-08T17:14:22.350Z
As long as someone can read it to work on it, they can wrongly push to a public repo unencrypted or just copy the files somewhere... That sounds just bringing complexity with no real solution.
Tensibai
CC BY-SA 3.0
2018-04-09T11:22:50.573Z
Cross posted on [Engineering](https://engineering.stackexchange.com/posts/21248/revisions), then migrated to [Softwarerecs](https://softwarerecs.stackexchange.com/q/49569/3474), then posted again on [Softwarerecs](https://softwarerecs.stackexchange.com/q/49568/3474), and posted here.
kenorb
CC BY-SA 3.0
2018-04-12T10:36:09.210Z
I joined this site just to vote to close (and forgot that I wouldn't have the rep :-) I am extremely surprised that there are, as yet, no closevotes, despite @kenorb's comment two days ago
Mawg
<git><python><encryption><git-hooks>
Git Files Encryption for Business
Emanuel Bennici
# Git Files Encryption for Business

(Asked by: username_0 on 2018-04-08)

I am using git and have the following problem:
In the company where I work you now want to protect the source code from theft.
So if for some reason a developer lets the source code of a project go along and sells it, for example.
To prevent this, I thought about it for a long time and came to the conclusion that encrypting the source code is the best choice.
Like [git-crypt](https://github.com/AGWA/git-crypt) does, that's a very good idea.
Only with one mistake:
If I add a user's GPG key, he can decrypt all files, and the protection measure would be worthless.
The files of the developer should be decrypted locally and only remotely. (This way the developer does not always have to encrypt, push, decrypt the files)

I tried to re-program [git-crypt](https://github.com/AGWA/git-crypt) in Python (because of cross-platform) but then failed due to the git attributes/smudge, clean filter drivers.

Do you know a possibility or an application that takes up exactly my problem?

**Tags:** git, python, encryption, git-hooks

> **Comments:**
> **username_1**: As long as someone can read it to work on it, they can wrongly push to a public repo unencrypted or just copy the files somewhere... That sounds just bringing complexity with no real solution.  
> **username_2**: Cross posted on [Engineering](https://engineering.stackexchange.com/posts/21248/revisions), then migrated to [Softwarerecs](https://softwarerecs.stackexchange.com/q/49569/3474), then posted again on [Softwarerecs](https://softwarerecs.stackexchange.com/q/49568/3474), and posted here.  
> **username_3**: I joined this site just to vote to close (and forgot that I wouldn't have the rep :-) I am extremely surprised that there are, as yet, no closevotes, despite @username_2's comment two days ago  

---

## 1 answers

### Answer by username_4 on 2018-04-08. Score: 9 | Accepted answer

There really is no way to take on your problem with git, which is to deny a developer with access to the code (required to work with it) the possibility to steal the code. This is because as soon as your developer has the code in a readable format (to program on it), he can do with it whatever he wants, anyways.

git-crypt has a totally different use, and is not related to your problem at all.

To solve your problem, there is basically only one possibility: lock the network in which the code resides down completely - make it so that there is no physical way to transfer the code to the outside. This could mean:

* No direct internet connection, obviously.
* No http/https proxy either, no mail clients etc.
* No way to add new devices to the network (unless through official ways). E.g., no unused network ports to plug anything in; no guest DHCP; MAC address filtering; no WIFI, smartphones; etc.
* No way to plug an USB device or other transfer mechanism into any devices.

This may sound harsh, but really is not. It could be as simple as keeping your code strictly within a set of VMs, accessed by something like Vmware Horizon or something like that, with cut&paste and file transfer disabled, of course. Be nice to your developers and allow them to transfer stuff *into* the environment (their favourite editor, for example).

The measures so far do not require any physical changes, i.e. your developers still can work remotely or in their usual unsecure office. Obviously, they still can go to extreme measures (screenshots on their client PC...) to get specific parts of the code page-by-page.

To go a step further, in increasing severity (although we are going into James Bond territory here...):

* Strict policy with severe punishment. Setup a specific contract which each emplyee which contains clauses as harsh as the laws of your country allow.
* Switching access to the limited network to a physical area in your office.
* Security measures like locked doors accessible to only specific personnel, video cameras with 24/7 human supervision and so on.
* 2-factor access (either 2 persons required to checkout code, or at least a physical TAN generator or something along those lines).

Note that in your case you want to make it hard for a thief who knows that he is doing something illegal and already has committed to doing a crime. He will not respect any "weak" protection (like rules/laws) anyways.

> **Comments:**
> **username_5**: You forgot: "No phones" ;) No technical approach can be 100% effective against determined enough malicious intent: some people have a really good memory, others can understand really well what the code does. In either case the code or its equivalent can be reproduced outside the technical barriers.  
> **username_4**: Absolutely, @DanCornilescu. I didn't want to stray too much into James Bond territory. ;)  
> **username_6**: Unless you can also control the remote access machines, there is no way to stop someone from screen shotting the code and running some OCR. Or in the worst case typing it out manually. Securing something that you also give access to is kind of pointless as it can all be gotten around.  
> **username_4**: Yes, I mentioned that, @username_6. This answer is not so much about providing a solution to an ultra secure high-risk military software development complex, but to put into perspective why `git-crypt` is not the correct tool of choice...  

---

