git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCHv2 0/13] credential helpers

From
Jeff King <peff@peff.net>
Date
Dec 7, 2011, 06:42 UTC
Message-ID
<20111207064231.GA499@sigill.intra.peff.net>
In-Reply-To
<7v7h29fkfy.fsf@alter.siamese.dyndns.org>
On Tue, Dec 06, 2011 at 01:40:17PM -0800, Junio C Hamano wrote:
Show 9 quoted lines
> Jeff King <peff@peff.net> writes:
> 
> >     ... You can now
> >     do: "git credential-store erase </dev/null" to erase everything
> >     (since you have provided no restrictions, it matches everything).
> 
> That "justification" does not sound so true to me but perhaps that is
> because it is unclear what "erase" means and what it means to give the
> operation parameters.

It's not meant to be a justification, but rather an explanation. I think the behavior is probably too dangerous to leave.

Show 6 quoted lines
> When I see "erase $foo", I would find it natural if $foo meant "if there
> is something that matches $foo, then please remove it, but keep everything
> else intact", and not the other way around "Match the existing entries
> against a pattern (or a set of matching patterns) I am giving you, and
> drop all the rest". So if I happen to give you an empty set, I would
> expect nothing is removed.

It does do the first thing you mentioned (you provide one pattern $foo, and we match the pattern you have given). It's just that the pattern you have specified is "everything". The problem is not in the matching, but in the pattern specification language.

This pattern:
  protocol=https
  host=github.com

means "match everything that uses https _and_ has a host of github.com". The username and path fields are not present, which implicitly means "don't care about them".

Similarly, this pattern:
  protocol=https

means "match everything that uses https". Everything else is not specified, and therefore we allow anything.

Then what does the empty pattern do? It cares about nothing, and therefore matches everything.

By itself, I don't think that is a problem. It's something you might want to specify, and it's logically consistent with the way the patterns are matched. What is dangerous, though, is that failing to provide input is byte-wise identical to the empty pattern. And that's why I say it's a pattern specification problem.

A rough BNF for the pattern format is something like:
  pattern = *line
  line = key "=" value
  key = *<any byte except NUL, "=", or "\n">
  value = *<any byte except NUL or "\n">

Because the pattern takes 0 or more lines and no terminator, we can't distinguish between empty or truncated input and the empty pattern. So one solution would be:

  pattern = *line "\n"
i.e., require a blank line terminator.
Does that explain the issue better?
-Peff
Previous: Junio C HamanoNext: Junio C Hamano
Message 23 of 30 in “[PATCHv2 0/13] credential helpers”
  1. Jeff KingDec 6, 2011
  2. 01/13 test-lib: add test_config_global variantJeff King, Dec 6, 2011
  3. 02/13 t5550: fix typoJeff King, Dec 6, 2011
  4. 03/13 introduce credentials APIJeff King, Dec 6, 2011
  5. 04/13 credential: add function for parsing url componentsJeff King, Dec 6, 2011
  6. 05/13 http: use credential API to get passwordsJeff King, Dec 6, 2011
  7. 06/13 credential: apply helper configJeff King, Dec 6, 2011
  8. Junio C HamanoDec 6, 2011
  9. Jeff KingDec 7, 2011
  10. Jeff KingDec 7, 2011
  11. 07/13 credential: add credential.*.usernameJeff King, Dec 6, 2011
  12. 08/13 credential: make relevance of http path configurableJeff King, Dec 6, 2011
  13. 09/13 docs: end-user documentation for the credential subsystemJeff King, Dec 6, 2011
  14. 10/13 credentials: add "cache" helperJeff King, Dec 6, 2011
  15. 11/13 strbuf: add strbuf_add*_urlencodeJeff King, Dec 6, 2011
  16. 12/13 credentials: add "store" helperJeff King, Dec 6, 2011
  17. Junio C HamanoDec 6, 2011
  18. Jeff KingDec 9, 2011
  19. 13/13 t: add test harness for external credential helpersJeff King, Dec 6, 2011
  20. Junio C HamanoDec 6, 2011
  21. Jeff KingDec 6, 2011
  22. Junio C HamanoDec 6, 2011
  23. Jeff KingDec 7, 2011
  24. Junio C HamanoDec 8, 2011
  25. Jeff KingDec 9, 2011
  26. Junio C HamanoDec 9, 2011
  27. Jeff KingDec 9, 2011
  28. Junio C HamanoDec 9, 2011
  29. Jeff KingDec 9, 2011
  30. Junio C HamanoDec 9, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.