softwareconstruction240 / autograder

Autograder for BYU's CS 240 Chess project
https://cs240.click
2 stars 2 forks source link

Catch commit backdaters #356

Closed frozenfrank closed 2 months ago

frozenfrank commented 2 months ago

Overview

This PR adds in logic that will detect the most common forms of backdating commits in an attempt to fake the unique day requirements for the branch. It will not give false-positives, but there are still ways around this verification.

How does it work?

The checks are designed to detect git's default behavior of keeping the time portion of the author timestamp the same as the commit timestamp. Typical commits are always exactly equal in their commit & author timestamps, and rebases will have differing time values as at least the seconds value will nearly certainly be different from the time they commit to the time they rebase.

Try it for yourself! Run these commands and observe the relationship between the CommitterDate timestamp and the AuthorDate timestamp:

git commit --allow-empty -m "Backdated relative 1" --date="1 day ago"
git commit --allow-empty -m "Backdated relative 2" --date="2 day ago"
git commit --allow-empty -m "Backdated fixed" --date="1/1/2000"
git log -n 3 --reverse
git log --format=fuller -n 3 --reverse

Testing

I have run my own tests on this code to verify that it works. In fact, it was in the process of testing this code that I created #355. However, I have not yet systemized the tests sufficiently to commit them into the repo. They are being worked on in #336.