Is “watermarking” code with random trailing whitespace a good way to detect plagiarism?

Consider this:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>int f(int x)
{
return 2 * x * x;
}
</code>
<code>int f(int x) { return 2 * x * x; } </code>
int f(int x)  
{    
    return 2 * x * x;      
} 

and this

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>int squareAndDouble(int y)
{
return 2*y*y;
}
</code>
<code>int squareAndDouble(int y) { return 2*y*y; } </code>
int squareAndDouble(int y)  
{    
    return 2*y*y;      
} 

If you found these in independent bodies of code, you might give the two programmers the benefit of the doubt and assume they came up with more-or-less the same function independently. But look at the whitespace at the end of each line of code. Same pattern in both. Surely evidence of copying. On a larger piece of code, correlation of random whitespace at line ends would be irrefutable evidence of a shared origin.

Now aside from the obvious weaknesses: e.g. visible or obvious in some editors, easily removed, I was wondering if it was worth deploying something like this in my open source project. My industry has a history of companies ripping off open source projects.

8

Since “Trim Whitespace on save” is a feature of many IDEs, I don’t think that this is good for anything.

First off, if someone rips off an open source project, presumably to create a closed source project, you are presumably not going to have access to the source of the closed source project without a lawsuit and enough evidence to get a court order to be able to examine the source code. That would tend to be a relatively high bar to clear before you can even get access to the source to compare the whitespace.

Assuming that you have the motivation to file suit and that you can gather enough evidence to suggest copying without using the source, though, it’s not obvious to me how beneficial white space analysis would be. If this is a real open source project that is successful enough to steal, it’s likely that the white space will change pretty regularly over time as people submit new versions of code so the “watermark” will change over time. If you’re assuming that the company that is ripping off the code is going to the effort of changing variable names and the spacing of the meaningful source (which would make applying changes from the open source project very challenging), it seems likely that the company would quickly just add a step to remove trailing whitespace from their code.

Most companies (and developers) that steal code do so much more blatantly. They’re just going to copy and paste the working code into their project and hit compile. They’re not going to bother changing variable names or changing the name of a procedure or anything else that requires them to understand and test the changes. There will generally be much, much bigger smoking guns than the number of spaces at the end of the line.

No.

Whitespace is insufficient to demonstrate a watermark as you’re suggesting.

Running the code through a style formatter that changes tabs to spaces or vice versa and part of your watermark has been changed. Additionally, based upon the style rules that are in place, trailing space could be truncated in order to comply with the style rule.

Presuming you could prove the “theft”, what would you do? You’ve made the code open-source, so you’re giving away the source code. And how would you gain access to their source code in the first place?

3

It could also be an indication of using the same crummy editor that doesn’t clean up line endings.

I found a few thousand lines of un-commented assembly code in a project I was working on over a decade ago. I wondered at the time if that meant it was plagiarized code with the comments stripped out.

Ultimately, this is a legal question and the best answer is probably, “it depends on the jurisdiction.” Copyright laws between the US and UK are similar, I don’t know about other countries, and certainly there are additional difficulties if the copyright his held in one country and infringed in another.

Using patterns of spacing at the end of lines is an interesting idea though. Some editors (like IntelliJ and Emacs) will automatically truncate all trailing whitespace for you, so I don’t know how effective it would be.

Here are Wikipedia’s guidelines (not legal advice, just what works for them).

I don’t believe it’ll be of any good, if the platform/language uses an formatting system (like those formatters found in the Delphi/FreePascal ecosystem, the pretty-print feature of VB.NET, the C# formatter on VS, etc)…

So if the code had passed by those tools, and considering that the tool is on its default settings, all watermarking is gone.

Some editors even have features to remove whitespaces at the end of a line (I think that the expression is “trailing blanks” – english is not my first language).

If the platform/language developers does not make much use of IDEs with autoformatting features, the watermarking can – in theory – work.

But I would not put much faith on just that.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật