{"thread":{"id":"53524","subject":"Anyone know what is creating commits with bogus dates?","startedAt":"2020-05-21T17:49:34Z","lastAt":"2020-05-21T19:55:16Z","messageCount":5,"participants":["Elijah Newren","Eric Sunshine","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"398370","messageId":"CABPp-BFfa6q96qMUN07Dq3di6d3WuUzhyktBytbX=FGgarXgjg@mail.gmail.com","threadId":"53524","inReplyTo":null,"subject":"Anyone know what is creating commits with bogus dates?","fromName":"Elijah Newren","fromEmail":"newren@gmail.com","sentAt":"2020-05-21T17:49:17Z","receivedAt":"2020-05-21T17:49:34Z","isPatch":false,"sender":{"key":"newren@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5455730?v=4"},"body":"Hi,\n\nI wanted to report that we seem to have a number of repos in the wild\nwith bogus (as in \"won't even parse\") dates.\n\nI first discovered such a repository in the wild a while ago with\nrails.git.  It has a commit with a recorded timezone of \"+051800\" for\nboth author and committer.  Everything else about the commit looks\nfine.  See https://github.com/rails/rails/commit/4cf94979c9f4d6683c9338d694d5eb3106a4e734.\n\nSome google searches at the time turned up a few other examples, all\nwith the same \"+051800\" issue.  I put a special workaround for it into\nfilter-repo because I figured it was slightly prominent but probably\nlimited to that special timezone.  The fact that it was six digits but\nthe last two were zeros made it seem not quite as bad as it could be.\n\n\nRecently, I've gotten a few reports of commits existing in live repos\nwith other forms of breakage.  Dates that correspond to roughly a\nhundred years in the future, and with timezone specifiers that are\neither 7 or 8 digits long and no leading or trailing zeros.  See\nhttps://github.com/newren/git-filter-repo/issues/88.\n\nIs there rogue software somewhere creating some bad commit objects?\nDoes anyone have any idea what might be causing these?  Any\nsuggestions on the right course(s) of action?\n\nRight now, I'm leaning towards saying fast-import is right to bail on\nthese, and maybe I'll investigate having filter-repo waste some cycles\nto try to detect these and report more helpful errors (though I really\nwant to avoid full sanity checking as that's expensive).  If I go that\nroute, I'll probably make it link to the example command I provided in\nthat bug report showing users how they can use filter-repo to fix\nthose problems.  Does that sound sane?  Anything I'm missing?\n\n\nThanks,\nElijah\n"},{"id":"398375","messageId":"CAPig+cSQoWuVyrOMynPUueYPaij6wgq8owwk-U9wE=wmVMNyRQ@mail.gmail.com","threadId":"53524","inReplyTo":"CABPp-BFfa6q96qMUN07Dq3di6d3WuUzhyktBytbX=FGgarXgjg@mail.gmail.com","subject":"Re: Anyone know what is creating commits with bogus dates?","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2020-05-21T18:12:09Z","receivedAt":"2020-05-21T18:12:23Z","isPatch":false,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Thu, May 21, 2020 at 1:49 PM Elijah Newren <newren@gmail.com> wrote:\n> I first discovered such a repository in the wild a while ago with\n> rails.git.  It has a commit with a recorded timezone of \"+051800\" for\n> both author and committer.  Everything else about the commit looks\n> fine.  See https://github.com/rails/rails/commit/4cf94979c9f4d6683c9338d694d5eb3106a4e734.\n>\n> Some google searches at the time turned up a few other examples, all\n> with the same \"+051800\" issue.  I put a special workaround for it into\n> filter-repo because I figured it was slightly prominent but probably\n> limited to that special timezone.  The fact that it was six digits but\n> the last two were zeros made it seem not quite as bad as it could be.\n\nIn git.git itself, there were a couple bugs fixed [1,2] in which the\nauthor header lacked a NUL-terminator after the timezone and in which\nan error condition wasn't checked which led to the last digit of the\ntimezone being duplicated, however, if I recall correctly, those only\ncropped up with \"git rebase -i --root\" (and only the author date-stamp\nwas affected), which doesn't seem to correspond to the cases you're\nfixing.\n\nPerhaps those commits were created by tools other than git.git?\n\n[1]: ca3e1826a0 (sequencer: fix \"rebase -i --root\" corrupting author\nheader, 2018-07-31)\n[2]: 0f16c09aae (sequencer: fix \"rebase -i --root\" corrupting author\nheader timezone, 2018-07-31)\n"},{"id":"398390","messageId":"20200521185753.GB1308489@coredump.intra.peff.net","threadId":"53524","inReplyTo":"CABPp-BFfa6q96qMUN07Dq3di6d3WuUzhyktBytbX=FGgarXgjg@mail.gmail.com","subject":"Re: Anyone know what is creating commits with bogus dates?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2020-05-21T18:57:53Z","receivedAt":"2020-05-21T18:57:56Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, May 21, 2020 at 10:49:17AM -0700, Elijah Newren wrote:\n\n> I wanted to report that we seem to have a number of repos in the wild\n> with bogus (as in \"won't even parse\") dates.\n> \n> I first discovered such a repository in the wild a while ago with\n> rails.git.  It has a commit with a recorded timezone of \"+051800\" for\n> both author and committer.  Everything else about the commit looks\n> fine.  See https://github.com/rails/rails/commit/4cf94979c9f4d6683c9338d694d5eb3106a4e734.\n> \n> Some google searches at the time turned up a few other examples, all\n> with the same \"+051800\" issue.  I put a special workaround for it into\n> filter-repo because I figured it was slightly prominent but probably\n> limited to that special timezone.  The fact that it was six digits but\n> the last two were zeros made it seem not quite as bad as it could be.\n\nI can't remember the source of the bug, but we've had a workaround in\nGitHub's incoming fsck checks to allow 6-digit zones like this since\nAugust 2011. I'm almost certain that it came up because of that\nrails/rails commit, but I don't remember the culprit implementation. I'm\nsure we would have dug it up and fixed it at the time.\n\nSadly our commit message for the fsck tweak gives no further details,\nnor can I dig up anything out of issues/etc.\n\nI _think_ it wasn't GitHub/grit which did this (the 0-prefixed tree\nmodes you might come across are, though). I couldn't find any mention of\nthe fix there, at least. I'd suspect perhaps libgit2, but I also\ncouldn't find any fix.\n\nBut I think it would be safe to assume the bug is long-since fixed, and\nit's nice if you can be a bit more lenient on the parsing for historical\nissues like this. Arguably fast-export ought to be normalizing it to\nsomething syntactically correct (just like we probably do with other\nunparsable dates), though I guess you could argue that a filter might\nwant to see the broken form in order to fix it in a custom way.\n\n-Peff\n"},{"id":"398394","messageId":"CABPp-BG+XdbeOgaL1Th6U8g-gRON41DCwZ-RDnN7CEgk2fvwDg@mail.gmail.com","threadId":"53524","inReplyTo":"20200521185753.GB1308489@coredump.intra.peff.net","subject":"Re: Anyone know what is creating commits with bogus dates?","fromName":"Elijah Newren","fromEmail":"newren@gmail.com","sentAt":"2020-05-21T19:31:36Z","receivedAt":"2020-05-21T19:31:53Z","isPatch":false,"sender":{"key":"newren@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5455730?v=4"},"body":"On Thu, May 21, 2020 at 11:57 AM Jeff King <peff@peff.net> wrote:\n>\n> On Thu, May 21, 2020 at 10:49:17AM -0700, Elijah Newren wrote:\n>\n> > I wanted to report that we seem to have a number of repos in the wild\n> > with bogus (as in \"won't even parse\") dates.\n> >\n> > I first discovered such a repository in the wild a while ago with\n> > rails.git.  It has a commit with a recorded timezone of \"+051800\" for\n> > both author and committer.  Everything else about the commit looks\n> > fine.  See https://github.com/rails/rails/commit/4cf94979c9f4d6683c9338d694d5eb3106a4e734.\n> >\n> > Some google searches at the time turned up a few other examples, all\n> > with the same \"+051800\" issue.  I put a special workaround for it into\n> > filter-repo because I figured it was slightly prominent but probably\n> > limited to that special timezone.  The fact that it was six digits but\n> > the last two were zeros made it seem not quite as bad as it could be.\n>\n> I can't remember the source of the bug, but we've had a workaround in\n> GitHub's incoming fsck checks to allow 6-digit zones like this since\n> August 2011. I'm almost certain that it came up because of that\n> rails/rails commit, but I don't remember the culprit implementation. I'm\n> sure we would have dug it up and fixed it at the time.\n\nWhat about 7- and 8- digit timezones (like the ones in the linked\nfilter-repo issue report)?  Do you currently prevent users from\npushing those to GitHub, or do you allow those too?\nI'm curious about whether there is anything else out there that might\nhelp flag these commits or if it's just filter-repo.\n\n> Sadly our commit message for the fsck tweak gives no further details,\n> nor can I dig up anything out of issues/etc.\n>\n> I _think_ it wasn't GitHub/grit which did this (the 0-prefixed tree\n> modes you might come across are, though). I couldn't find any mention of\n> the fix there, at least. I'd suspect perhaps libgit2, but I also\n> couldn't find any fix.\n>\n> But I think it would be safe to assume the bug is long-since fixed, and\n> it's nice if you can be a bit more lenient on the parsing for historical\n> issues like this. Arguably fast-export ought to be normalizing it to\n> something syntactically correct (just like we probably do with other\n> unparsable dates), though I guess you could argue that a filter might\n> want to see the broken form in order to fix it in a custom way.\n\nIf we're going to be more lenient on the parsing, does that suggest\nfast-import shouldn't die on these?  Currently, fast-import is the\nthing dying, not fast-export or filter-repo (though filter-repo of\ncourse halts when it notices that fast-import has died under it).\n\nI put in special-case code in filter-repo to munge the +051800\ntimezone case to keep fast-import from dying, but these new cases seem\nto suggest it's not just one bad timezone that I can check for and\ncorrect, but rather that they are completely random 7- or 8- (or who\nknows how many) digit timezones coupled with bogus\n(century-into-the-future) unix epochs.  I'm a little less comfortable\nworking around all of these than the very specific +051800 issue.  On\nthe filter-repo side, I think the most I would want to do here is\nprovide cleaner warning or error messages than \"fast-import died,\nhere's a traceback.\"  But I'm unusre if there are other steps we\nshould take as well, such as making the fast-import parser more\nlenient.\n"},{"id":"398397","messageId":"20200521195513.GA1542632@coredump.intra.peff.net","threadId":"53524","inReplyTo":"CABPp-BG+XdbeOgaL1Th6U8g-gRON41DCwZ-RDnN7CEgk2fvwDg@mail.gmail.com","subject":"Re: Anyone know what is creating commits with bogus dates?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2020-05-21T19:55:13Z","receivedAt":"2020-05-21T19:55:16Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, May 21, 2020 at 12:31:36PM -0700, Elijah Newren wrote:\n\n> > I can't remember the source of the bug, but we've had a workaround in\n> > GitHub's incoming fsck checks to allow 6-digit zones like this since\n> > August 2011. I'm almost certain that it came up because of that\n> > rails/rails commit, but I don't remember the culprit implementation. I'm\n> > sure we would have dug it up and fixed it at the time.\n> \n> What about 7- and 8- digit timezones (like the ones in the linked\n> filter-repo issue report)?  Do you currently prevent users from\n> pushing those to GitHub, or do you allow those too?\n> I'm curious about whether there is anything else out there that might\n> help flag these commits or if it's just filter-repo.\n\nOur loosening allows any size:\n\n--- a/fsck.c\n+++ b/fsck.c\n[...]\n@@ -772,14 +778,16 @@ static int fsck_ident(const char **ident,\n        if ((end == p || *end != ' '))\n                return report(options, oid, type, FSCK_MSG_BAD_DATE, \"invalid author/committer line - bad date\");\n        p = end + 1;\n-       if ((*p != '+' && *p != '-') ||\n-           !isdigit(p[1]) ||\n-           !isdigit(p[2]) ||\n-           !isdigit(p[3]) ||\n-           !isdigit(p[4]) ||\n-           (p[5] != '\\n'))\n+       if (*p != '+' && *p != '-')\n                return report(options, oid, type, FSCK_MSG_BAD_TIMEZONE, \"invalid author/committer line - bad time zone\");\n-       p += 6;\n+       p++;\n+\n+       do {\n+               if (!isdigit(*p))\n+                       return report(options, oid, type, FSCK_MSG_BAD_TIMEZONE, \"invalid author/committer line - bad time zone\");\n+               p++;\n+       } while (*p != '\\n');\n+\n\nI don't remember the nature of the bug well enough to know if the longer\nones are likely to have the same cause.\n\n> > But I think it would be safe to assume the bug is long-since fixed, and\n> > it's nice if you can be a bit more lenient on the parsing for historical\n> > issues like this. Arguably fast-export ought to be normalizing it to\n> > something syntactically correct (just like we probably do with other\n> > unparsable dates), though I guess you could argue that a filter might\n> > want to see the broken form in order to fix it in a custom way.\n> \n> If we're going to be more lenient on the parsing, does that suggest\n> fast-import shouldn't die on these?  Currently, fast-import is the\n> thing dying, not fast-export or filter-repo (though filter-repo of\n> course halts when it notices that fast-import has died under it).\n\nAh, I thought filter-repo was noticing. I think it would be nice for\neither fast-export or fast-import to normalize syntactically invalid\nvalues to something sane (like just resetting a bogus timezone to\n+0000). I could see arguments for putting it in either spot (putting it\nin fast-import has the downside that we wouldn't catch invalid output\ngenerated by a script; putting it in fast-export has the downside that\nyou can't notice and fix it up yourself if you choose to).\n\nProbably it should be in fast-export, but with an option to turn it off\nfor people who want more control (or leave it off by default, and let\npeople who run into problems turn it on). We already have similar\noptions for handling un-exportable cases like signed tags.\n\n> I put in special-case code in filter-repo to munge the +051800\n> timezone case to keep fast-import from dying, but these new cases seem\n> to suggest it's not just one bad timezone that I can check for and\n> correct, but rather that they are completely random 7- or 8- (or who\n> knows how many) digit timezones coupled with bogus\n> (century-into-the-future) unix epochs.  I'm a little less comfortable\n> working around all of these than the very specific +051800 issue.  On\n> the filter-repo side, I think the most I would want to do here is\n> provide cleaner warning or error messages than \"fast-import died,\n> here's a traceback.\"  But I'm unusre if there are other steps we\n> should take as well, such as making the fast-import parser more\n> lenient.\n\nI think if filter-repo does anything, it would probably be to read any\nsyntactically invalid timezone and normalize it. But again, I think it\nwould be fine to push that into fast-export.\n\n-Peff\n"}]}