89

Recently I've been working on making some API calls to a 3rd party. I couldn't find anything available to use, so I had to do it from the ground up. Now I'm wondering whether it would be okay for me to rewrite all the platform specific parts and release that as open source (I'd say that would change ~50% of the code)?

Now the API doc that the other company gave me says "proprietary and confidential", but I assume that would apply only to the doc itself. Also when I asked them for help at one point they told me they don't support the language I am using. I have not signed a NDA specific to this, I have a general one in regards to client's data and info (and these are not clients). I am a bit hesitant to ask someone from my company about this since I have 0 experience when it comes to this sort of stuff, and I don't know whether they'd view it negatively..

edit

Thank you all for the advice. I do know that the code I write belongs to my employer, but I thought since most of what we do is platform dependent I'd have to majorly restructure it so it can work independently, and the rest could be considered a common way to do things. As for the proprietary API to which it would become a wrapper, it has wsdl and xsd schemas which can be accessed publicly (albeit you'd have to know where to get them), based on which a person can figure out how to use it. I guess the best thing really would be to speak to someone.. I'll let you know how it goes

3

9 Answers 9

201

I have actually done this. At one point I wrote some code at work, and I realized that it would be generally useful, well beyond the scope of the specific project I was working on. So I asked my boss (who was also the CEO; it was a very small company) if it was OK to publish this as open source, and he said sure, that would be fine.

Note: that last bit is very, very important. As an employee, the code I wrote for the company was "work made for hire," meaning that my creative product was not my property, but my employer's. So without the permission of the legal owner, publishing it would have been at the very least a firing offense, and quite possibly a crime as well.

(IANAL, but this is a pretty well-understood and broadly accepted interpretation of applicable US law.)

16
  • 124
    +1 Yes, this is the only way to be able to release the code. You need to have permission from the company, IN WRITING, saying that you are allowed to adapt the code for public consumption.
    – David K
    Commented Feb 14, 2019 at 13:49
  • 13
    This fine answer would be even better yet if it acknowledged that legally you do not need any permission if you recreate the work independently without using any of the resources provided by the employment.
    – Aaron
    Commented Feb 14, 2019 at 16:12
  • 14
    @Aaron That's actually not entirely true. Some companies (used to, at least) force engineers (software and other) to sign contracts that would designate any IP / things they created, period, were company property. Whether or not you were doing it with the help of company resources, on or off company time, or on or off company equipment was irrelevant. Anything you created belonged to them. I haven't heard of any around for some time, but it's still something OP would need to assess. Commented Feb 14, 2019 at 17:13
  • 17
    @DavidK 's comment can't be stated strongly enough. GET IT IN WRITING
    – J...
    Commented Feb 14, 2019 at 17:31
  • 8
    @JohnVandivier You're right the verbal agreements can be binding, but if the boss who told you it was okay later says "I never told him he could do that!", then you're out of luck. It's not about having a legally binding agreement - it's about being able to prove that you were given permission.
    – David K
    Commented Feb 14, 2019 at 17:45
77

Code you wrote for work is property of your company. Publishing it, as open source or otherwise, is copyright infringement and will get you fired. It also creates a legal nightmare for anyone taking this code, assuming it is open source, when in reality it is owned by your company.

And “adapting” the code doesn’t help you. You’re creating a derivative work. Which is copyright infringement before you even copy your derived work.

1
  • Comments are not for extended discussion; this conversation has been moved to chat.
    – user44108
    Commented Feb 15, 2019 at 13:49
48

I disagree with the majority here. Clearly the majority of folks are saying you shouldn't do this. I don't necessarily disagree with that, but the subtext and in many cases the overt message is you legally cannot do this rather than simply you shouldn't do this. The legal correctness of that message is far from clear in your case and in general.

It's nice to see that, while I'm in the minority, it's not so obscure that no other answers agree with my view, or that all answers which agree with my view are negatively rated. I agree with the spirit of @Kittoes0124's message.

As the minority, we should certainly learn something from the cautious majority: Many developers have been fired or worse for copyright infringement or other intellectual property violation. The result, unfortunately, has been an overshooting of defensiveness in the community, and the result is damage to the Open Source community and society as a whole, which benefits from a strong OS community.

One apropos comment referenced Clean Room Design, which is a legally blessed, tried-and-true method of feature replication without copyright infringement. Notice what the linked article says about Clean Room Design, with specific legal case backing:

Clean room design is usually employed as best practice, but not strictly required by law. In NEC Corp. v Intel Corp. (1990), NEC sought declaratory judgment against Intel's charges that NEC's engineers simply copied the microcode of the 8086 processor in their NEC V20 clone. A US judge ruled that while the early, internal revisions of NEC's microcode were indeed a copyright violation, the later one, which actually went into NEC's product, although derived from the former, were sufficiently different from the Intel microcode it could be considered free of copyright violations.

This is the correct standard in the US. It's based on case law, not developer opinion or anecdote. You are allowed to refer to proprietary code and personal experience for reference, and even use that literal code as a concrete starting point, but the final code must be "sufficiently different."

It seems to be an ambiguous and arbitrary standard because it is exactly so. Judges vary in leniency of interpretation of the rule, but the rule is clear. The common wisdom is "better safe than sorry," and this is why many professionals sadly avoid public display of any code. It is generally smarter and less risky to seek internal corporate approval, but it is not generally legally required. It may be legally required if you signed some additional documents, or if your jurisdiction has special law.

An important note in your specific case is that there is an important difference between the code you propose to ship and the original code. You state that the original code is platform-specific and you propose to ship platform-independent code. This means there are use cases which the legacy code cannot support. This is one method of demonstrating significant difference. You could strengthen this difference further by making your solution intentionally incompatible with the legacy platform. This would mean there is no use case overlap at all.

I'm not a lawyer and this is not legal advice. I do recommend you check with a lawyer if you decide to do anything like this. I see plenty of US legal precedent to support the fact that when you code you will naturally draw on prior experience and knowledge, including referring to concrete examples of code, and this doesn't make Open Source illegal.

Using the same syntax need not be a concern. Many languages and libraries provide only one syntactic way of doing a certain thing, and best practices exist for functions, variables, and so on, such that using even the same variable names may be unavoidable for feature replication. In cases like that, significant difference may be impossible and therefore not reasonably required.

Keep in mind that these general notions would be completely indefensible if you signed a specific NDA or certain other documents.

Two other related notes. First, IP violations are subject to a statute of limitations in the USA (source):

Infringement of a copyright may result in civil and/or criminal liability. The statute of limitations for criminal proceedings is five years, while for a civil action it is three years.

A second note is that there are only 4 (AFAIK/IANAL) kinds of intellectual property (source):

  1. Copyright
  2. Trademark
  3. Patent
  4. Trade Secrets

If you are dealing with IP which doesn't fall into categories 1-3, it is less legally problematic to adapt the code for own use. It seems difficult to me that anyone could argue X is a Trade Secret if X is a common pattern or feature in other software, particularly if it already exists in Open Source projects.

12
  • 2
    There is at least (in the EU) database rights too. Given that I have come up with one more, there are probably others too. Commented Feb 14, 2019 at 17:32
  • 9
    This is a very thorough and well-thought out answer, and good background info! I would still strongly recommend to OP that they check with their employer first because even if what they wanted to do turned out to hold up in court, they probably aren't going to want to be taken to court by their employer (nor be fired, which would likely proceed being taken to court). The best way to avoid this possibility is to check first.
    – bob
    Commented Feb 14, 2019 at 17:46
  • 2
    @bob Absolutely agree. Ideally, OP should never need to go to court. Glad it contained some useful info! Commented Feb 14, 2019 at 17:48
  • 1
    @Kittoes0124 That's because every contract of employment I have seen, contains a contract making it so. (Admittedly I've only ever seen about 10.) Commented Feb 15, 2019 at 5:26
  • 3
    This answer states it disagrees with the majority, and then proceeds to agree with them that you shouldn't adapt your employer's code. It then contains a useful suggestion about clean room design (which is not adaptation). I'd remove all the stuff about disagreeing as it doesn't seem to add anything.
    – Rob Grant
    Commented Feb 16, 2019 at 14:29
19

The short answer is not without express permission.

You need to ask your superiors. Quite possibly your manager may need to pass the question up the chain.

If you are lucky, the company has a process for this. If not, it may be helpful to find out if this has previously been done. Ask your coworkers. A previous example of having code released is a very helpful precedent. An example from another company may also help as will resources from the Free Software and Open Source Community that explain the process and implications. Anything that helps your superiors to make this easier.

Before releasing any code, the company needs to audit it to make sure that the code is fully owned by the company.

For the more detailed legal implications and resources to help ease the process, you may get more helpful answers on https://opensource.stackexchange.com/

14

While the answers provided thus far are good advice, I think they go way too far. The code you wrote belongs to your employer but they generally do not own the knowledge and skills you gained while implementing it.

Let's pretend you were tasked with implementing a random number generator using a proprietary API that is provided to you by a third party; for simplicity, this API consists of the single signature public byte[] GetRandomBytes(int length). You're required to implement a new class RandomNumberGenerator, using the open source algorithm (such as PCG or Xoroshiro) of your choice, that exposes the APIs public long GetNextInt64() and public long GetNextInt64(long lowerBound, long upperBound).

Your employer would own the specific code that you wrote but that's pretty much the end of it. Nothing prevents you from later implementing your own version of an RNG that depends on, say, /dev/random for the source of random bytes. It might be a wise defensive move to use a different algorithm and function signatures (where it makes sense to do so) but this matters less and less the more one depends on open source material.

There are definitely plenty of cases where one should follow the advice so far of DON'T DO IT! but the vast majority of the things that us programmers are asked to do fall into the category of general knowledge.

8
  • 2
    Why put yourself through the possibility of trying to convince your current employer that the code that you have published is significantly different from the code at work? (BTW Writing code is not general knowledge)
    – Ed Heal
    Commented Feb 14, 2019 at 15:38
  • 3
    @EdHeal I want to make the world a better place and don't mind taking some minimal risk to do so. Sure, with the right motivation, a company could try to come after me in court but the far more likely outcome is that I just end up with a nice portfolio of work; if I'm truly lucky then many people will actively be using it! And yes, code can absolutely be general knowledge. For example, no company can lay claim to (ax + c) % m. They might have a patent on a particular technique but that's why one must be careful to rely on open source when writing open source. Commented Feb 14, 2019 at 16:50
  • I agree with your first statement but not with your example. If you implement a generator wrapper for your employer, the value of the intellectual property is in the wrapper not the generator. If you extends the wrapper to support another generator it's still a derived work of the wrapper that belongs to your employer. If you rewrite one from scratch implementing the same logic, it's still a derived work in the eye of IP law. If you use neither the code, nor the "idea behind the code" then you have nothing to publish in the first place.
    – zakinster
    Commented Feb 14, 2019 at 18:13
  • 3
    @zakinster Nonsense, think about what you're implying here, no company can lay claim to the "idea behind the code" in my example because it isn't original. If X idea already has an open source implementation then one isn't barred from writing their own derivative simply because of the fact that they implemented a version of X at their formal job. The interface described in my example has so many existing implementations that it would be impossible for a company to legitimately lay claim to the concept. Again, one should be cautious but let's not go overboard... Commented Feb 14, 2019 at 18:30
  • 2
    @Kittoes0124 Yes, I agree, if you don't reuse anything, theoretically, you can. But I challenge the motive behind it. My point is that if there's a motive to publish something, it means there is value to be reused and the value belongs to the original owner. It's not 100% true, as instance in your case, there is no value reused but only skills in Y and knowledge of X. But I still think it's a very specific case and in general when this question is asked, motive = reuse value.
    – zakinster
    Commented Feb 14, 2019 at 19:17
6

In my company we have an open source policy.

To use open source, the license has to be cleared for use, and all the restrictions stipulated.

To contribute to open source, the code has to be prepared and submitted for review and approved.

You need to find out the policies in Your company.

1
  • I believe this is the most correct answer. To avoid any possible issues, get approval from your company before you release it to Open Source.
    – Nobody
    Commented Feb 15, 2019 at 12:35
1

Can I adapt code I wrote for work and release it as open source

Never without an explicit authorization from the owner of the intellectual property, which may be your employer, your client or your employer's client.

Programmers are not code monkeys, the value in a program is not only in the code but also in the implementation logic, i.e. the original idea behind the code.

If you produce a new code using any part of the existing code, or even any original idea behind the code, you're producing a derived work which must be authorized by the owner of the original work.

If you re-use neither the code nor an original idea, then you have nothing to publish in the first place until you use only your skills to produce a new unrelated work.

1

If you want the code to be usable open source, you need to get the license legally out there. Releasing code with an invalid source license so it's available is setting up legal time bombs for people who use it in good faith. They can be sued for damages, and can get injunctions against using the copyrighted material. You don't want to do this. You need to have the distribution be clearly legal.

To avoid this, you need some sort of release from the owner, allowing the program to be distributed under an Open Source license. This has to be done by someone with adequate authority, and you need to determine who that is. This should be written and signed. A verbal agreement is technically sufficient, but it's hard to prove such verbal agreements, and easy for the person saying it's OK to deny that he or she said such a thing or meant that, and so lawsuits are quite possible.

I'm happy to see someone trying to put software out under an Open Source license, but putting it out under an invalid license is a Bad Idea.

0

I am not a lawyer. But a software developer (in France), and I do contribute (professionally) to open source projects, and sometimes even develop open source software professionally.

You need to get permission from your employer.

Remember that source code is often protected by copyright or trade secrets, and the source code you write at your workplace belongs (unless specified in writing by some contract) to your company. In some work contracts, every code you write (even at home) belongs to your employer.

A border-case line might be to rewrite that code in some other programming language (e.g. write in Rust at home something you wrote at work in C at your office). But even for that case, you'll better ask your boss (at least by email) and get permission from him/her.

In Europe, algorithms usually cannot be protected (but their source code implementation can and often is). In the USA, I heard that even algorithms can be patented.

BTW, you don't want trouble with your boss. So you should inform and ask him anyway. He could decide to help you officially putting that code as open source, or he could remind you that you could put yourself in big trouble. If you have some (written, at least in email) approval from your boss, at least you are acting in good faith.

You must log in to answer this question.