mirror of
https://github.com/sourcegraph/sourcegraph.git
synced 2026-02-06 19:51:50 +00:00
At some point in the past, we noticed that passing /dev/passwd and /dev/null to `git diff` allows to view the file contents, even though it's not part of the repo itself. That allows to read arbitrary files on disk, so we had to add in-app validation for file paths, including relative paths. That makes the validation much more complex and harder to reason about, and requires that we didn't make a mistake. Instead, we switch to `git diff-tree` which validates paths are part of the tree properly. By that, we can remove a bunch of complexity around git diff argument validation. See here for the difference: ``` ➜ sourcegraph git:(main) git diff-tree --find-renames --full-index --inter-hunk-context=3 --no-prefix -- /etc/hosts /dev/null fatal: /etc/hosts: '/etc/hosts' is outside repository at '/Users/erik/Code/sourcegraph/sourcegraph' ➜ sourcegraph git:(main) git --no-pager diff --find-renames --full-index --inter-hunk-context=3 --no-prefix -- /etc/hosts /dev/null diff --git etc/hosts etc/hosts deleted file mode 100644 index deadbeef..0000000000000000000000000000000000000000 --- etc/hosts +++ /dev/null @@ -1,16 +0,0 @@ -## -# Host Database -# -# localhost is used to configure the loopback interface -# when the system is booting. Do not change this entry. -## -127.0.0.1 localhost ``` This PR also skips over arguments past the `--` boundary which in git means "everything after this will not be interpreted as an argument". This previously caused `git cat-file HEAD -- -file.txt` to fail argument validation, although it's perfectly valid and not a risk. Test plan: Adjusted the tests for argument validation and existing tests for diff and integration and E2E tests are still passing. |
||
|---|---|---|
| .. | ||
| appliance | ||
| batcheshelper | ||
| blobstore | ||
| bundled-executor | ||
| cody-gateway | ||
| embeddings | ||
| enterprise-portal | ||
| executor | ||
| executor-kubernetes | ||
| frontend | ||
| gitserver | ||
| loadtest | ||
| migrator | ||
| msp-example | ||
| pings | ||
| precise-code-intel-worker | ||
| repo-updater | ||
| searcher | ||
| server | ||
| symbols | ||
| syntactic-code-intel-worker | ||
| telemetry-gateway | ||
| worker | ||
| README.md | ||
This directory contains Sourcegraph services and binaries.
When a services is added, removed, or when a service's dependencies change, update our architecture diagram.