Commit Graph

37117 Commits

Author SHA1 Message Date
Shivasurya
9e95499625
chore(security) : upgrade src-cli version to address CVE (#63750)
Docker images executor, executor-kubernetes, bundled-executor has
reported high/critical CVE-2024-24790 , CVE-2023-45288 reported on
golang stdlib. Upon testing, src version 5.3.0 was using `1.20.x` as per
e8e79e0311

This pull request attempts to upgrade src version to 5.4.0

## Test plan

- CI 🟢 
- src version should report 5.4.0 (I built the image locally and tested
it)
`docker run --platform linux/amd64 -it --entrypoint /bin/sh
executor:candidate`

## Changelog

<!-- OPTIONAL; info at
https://www.notion.so/sourcegraph/Writing-a-changelog-entry-dd997f411d524caabf0d8d38a24a878c
-->

Upgrade src-cli version to 5.4.0 to address CVE-2024-24790 ,
CVE-2023-45288
2024-07-10 09:57:16 -04:00
Christoph Hegemann
d3df71ef98
Adds a test for search-based usages (#63610)
Closes
https://linear.app/sourcegraph/issue/GRAPH-726/test-syntactic-and-search-based-usages

Testing just the search-based usages just requires mocking the
SearchClient, which works out nicely.

## Test plan

The whole PR is just a test
2024-07-10 13:22:53 +00:00
Jean-Hadrien Chabran
2645a9b04d
chore(migrator): bump migration archive (#63752)
Routine update, as this is still a manual process.

## Test plan

CI
2024-07-10 15:10:32 +02:00
Nelson Araujo
08ed73cd3d
Convert Appliance Maintenance UI to Bazel (#63661)
Write Bazel machinery for the Appliance maintenance UI.

## Test plan

- `bazel build ...` passes
- `pnpm run dev` launches app successfully

---------

Co-authored-by: Jean-Hadrien Chabran <jh@chabran.fr>
2024-07-10 13:47:18 +02:00
William Bezuidenhout
ddc27b887f
feat(sg/cloud): trigger build on cloud-ephemeral pipeline (#63748)
Currently if a cloud ephemeral build is trigger it is triggered on the
`main` sourcegraph pipeline. Once a build a triggered and a commit is
subsequently pushed the previous build is cancelled - which means the
Cloud Ephemeral build is cancelled leading to a failed deployment.

In this PR, we instead trigger a build on the Cloud Ephemeral pipeline.
Which is the _exact_ pipeline as `sourcegraph` main but:
- sets the pipeline env to always have `CLOUD_EPHEMERAL=true`
- does not cancel previous builds

## Test plan
https://buildkite.com/sourcegraph/cloud-ephemeral/builds/1


## Changelog
* `sg cloud eph` will now trigger builds on the `cloud-ephemeral`
pipeline
2024-07-10 11:58:46 +02:00
Varun Gandhi
743134a193
docs: Fix inaccuracies in RangeInput GraphQL docs (#63640) 2024-07-10 09:47:10 +00:00
sourcegraph-buildkite
8efbdc2d49
security: Auto-update package lockfiles for Sourcegraph base images (#63606)
Automatically generated PR to update package lockfiles for Sourcegraph
base images.

Built from Buildkite run
[#281769](https://buildkite.com/sourcegraph/sourcegraph/builds/281769).
## Test Plan
- CI build verifies image functionality

Co-authored-by: Buildkite <buildkite@sourcegraph.com>
2024-07-10 09:21:27 +01:00
Felix Kling
a8639c1328
chore(svelte): Update cody web version (#63747)
Similar to https://github.com/sourcegraph/sourcegraph/pull/63742 this
updates to the latest cody web version in the new web app.

## Test plan

Manual testing
2024-07-10 07:58:21 +00:00
Michael Bahr
bd1488167f
fix: remove watch path that's gone (#63746)
https://github.com/sourcegraph/sourcegraph/pull/63736 removed rockskip
files, which lead to `sg start` failing because it was still watching
those. This PR removes the watch and lets `sg start` succeed again.

## Test plan

Existing CI, manual test of `sg start`

## Changelog

<!-- OPTIONAL; info at
https://www.notion.so/sourcegraph/Writing-a-changelog-entry-dd997f411d524caabf0d8d38a24a878c
-->
2024-07-10 06:56:25 +00:00
Vova Kulikov
fea468bd14
Bump cody-web-experimental to 0.2.4 (#63742)
Follow up for https://github.com/sourcegraph/cody/pull/4826

In the latest release, 0.2.4, we fixed the problem that @fkling found
about links
[here](https://linear.app/sourcegraph/issue/SRCH-633/links-in-the-prompt-has-incorrect-url-in-cody-web#comment-b9427c46);
cody assistance can render links in its response via markdown, and in
0.2.3, these links had deep link vscode command, which didn't work
properly in cody web. Now it renders plain links when it's rendered for
Cody Web.

## Test plan
- Check that links that Cody assistance provides work properly and don't
have any deep links command

<!-- REQUIRED; info at
https://docs-legacy.sourcegraph.com/dev/background-information/testing_principles
-->

## Changelog

<!-- OPTIONAL; info at
https://www.notion.so/sourcegraph/Writing-a-changelog-entry-dd997f411d524caabf0d8d38a24a878c
-->
2024-07-09 21:23:08 -06:00
Erik Seliger
2e392e0e89
Unexport some externally irrelevant symbols from uploadstore (#63647)
These symbols aren't used outside of the package, so unexporting them
for a cleaner API surface.

Test plan:

Go compiler doesn't complain.
2024-07-10 02:45:02 +02:00
Erik Seliger
9435fde3a2
Remove unused package (#63646)
This package isn't in use anymore, so cleaning it up.

Test plan:

Go compiler doesn't complain.
2024-07-10 02:30:28 +02:00
Erik Seliger
eb39e68761
scheduler: Simplify query for uncloned repos (#63681)
Since we removed on-demand cloning, the scheduler is now expected to always contain all repositories. Thus, we no longer need to constrain the set of uncloned repos to a ginormous ID list.

Test plan:

CI still passes.
2024-07-10 02:24:32 +02:00
Erik Seliger
8bc8ad27bd
phabricator: Move syncer to worker (#63682)
This syncer doesn't depend on anything in repo updater, so we're moving it to worker instead, where it can selectively be disabled and is properly monitored.

Test plan:

CI passes, code review.
2024-07-10 02:24:18 +02:00
Erik Seliger
ac0d497315
Remove old cache cleanup method (#63645)
We have been using v2 data since >5 years now, this should be safe to
remove.

As a side-effect, we have one less background task running in frontend,
which means it ran N times in horizontally scaled environments, which
isn't exactly useful.

Test plan:

Code review.
2024-07-10 02:04:53 +02:00
Erik Seliger
a32b6131f3
codygateway: Use only one redis pool and make REDIS_ENDPOINT a clear requirement in config (#63625)
Currently, nothing really tells that Cody Gateway needs redis, the env
var for finding the address is hidden somewhere deep in the redispool
package.
In practice, we only use one redis instance, but at some point we
started using both redispool.Cache and redispool.Store, which means we
maintain two connection pools, leading to more than expected
connections.

Test plan:

Code review and CI.
2024-07-10 01:54:24 +02:00
Erik Seliger
41fdc5cc7c
symbols: Make symbols specific code internal (#63736)
This PR restructures the packages to move all symbols-only code into the
symbols service. This helps to reason better about which service is
accessing what datastores.

Test plan:

Just moved code, compiler and CI are happy.
2024-07-10 01:26:22 +02:00
Erik Seliger
169db11ce6
rcache: Explicitly pass redis pool to use (#63644)
Recently, this was refactored to also allow using the redispool.Store.
However, that makes it very implicit to know where something is being
written, so instead we pass down the pool instance at instantiation.

This also gives a slightly better overview of where redispool is
actually required.

Test plan: CI passes.
2024-07-10 01:23:19 +02:00
Erik Seliger
60dc37d1a5
symbols: Minor code cleanup (#63708)
Was reading through the service, found these things and figured why not
commit them.

Test plan:

CI.
2024-07-10 01:22:03 +02:00
Stephen Gutekanst
bd3baef6e0
pass ModelConfigInfo down to client.Get() for self-hosted-models (#63739)
This PR has a single goal: pass a new `ModelConfigInfo` type, which has
the `Provider` and `Model` we should use to serve a completions request,
down into `client.Get()`

This PR explicitly only handles the case we care about for Self-hosted
models, and all pieces of logic that I expect will be
replaced/superseded by your work @chrsmith are annotated with `//
TODO(slimsag): self-hosted-models:` comments so we can easily find and
remove them when your work is ready.

Every location I have modified has been carefully wrapped in an if
statement like `if conf.Get().SiteConfig().ModelConfiguration != nil` to
ensure that this change _only_ affects people who set the new
`"modelConfiguration"` site config property.

## Test plan

1. Configured `"modelConfiguration"` and removed `"completions"` in my
dev instances' site config.
2. Used VS Code chat to confirm I see this codepath is connected
end-to-end and I get a `TODO` error back:

<img width="679" alt="image"
src="https://github.com/sourcegraph/sourcegraph/assets/3173176/d3c07ffe-7ec2-4ad9-9251-2272ce36d44b">

## Changelog

N/A

---------

Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
2024-07-09 15:30:37 -07:00
Felix Kling
82372119fe
fix(svelte): Prefill search home page query input with (default) context filter (#63740)
Closes srch-103

Currently we don't show the global context filter on the search home
page or the search results page (global context is the default context).

This commit does two things:

- It prefills the search input on the search homepage with the user's
default context (like the React app)
- It the logic that pre-processed the search query and removed the
context filter if it was global.

In other words we simplify the query logic by showing/submitting the
search query as is. Notably this doesn't affect how the search input
works on repo pages.


## Test plan

- Opening the search home page pre-fills the query input with the
default search context
- Submitting a query without a `context:` filter does not add a
`context:` filter to the URL or the search input
- If a query contains `context:global` that filter is preserved in the
query input (it wasn't before)
2024-07-09 22:02:04 +00:00
Felix Kling
b9dd3a774d
chore(svelte): Use MDI icons for seach input pattern type toggles (#63733)
We don't like the style/alignment of the Lucide case sensitivity and
regex icons (the structural search icon seems fine). This commit
switches them back to the MDI icons that we used before.

Solution or temporary workaround (tbd) for srch-544


## Test plan

Manual testing.
2024-07-09 21:56:00 +00:00
Matthew Manela
4c3985e16f
feat(Source): Properly render multi-line changelist messages from Perforce (#63728)
Fixes SRC-431

Mutli-line perforce changelist descriptions were not being handle since
the code implicitly assumed they could not exist. This change enables
support for them.


## Screenshots

**Changelist view with both single and multiline commits**

![image](https://github.com/sourcegraph/sourcegraph/assets/304410/8c7ead01-fdec-461c-826b-83013f89ad77)

**Changelist view with expanded commit message**

![image](https://github.com/sourcegraph/sourcegraph/assets/304410/a16c8637-7180-4631-88cb-39b4cc49a74c)

**Individual changelist item**

![image](https://github.com/sourcegraph/sourcegraph/assets/304410/c63f0a49-f6a9-430c-9caf-0480c17bb64e)


## Test plan
1. Update unit tests
2. Validate both P4 and non-p4 commits work
3. Validate on s2

## Changelog

- Properly render multi-line perforce changelist descriptions
2024-07-09 17:52:05 -04:00
Robert Lin
28f797e866
feat/enterpriseportal: database layer for subscriptions upsert (#63703)
Implements upsert for all the subscriptions fields in the DB client. As
part of this I generalized the logic for building upsert DB interactions
into a new `upsert` package, because this pattern is a common one we'll
need to implement to maintain various AIP-update-compliant endpoints,
which specifies various upsert behaviours: https://google.aip.dev/134

Part of CORE-216
Part of CORE-156

## Test plan

Integration tests against DB
2024-07-09 14:35:00 -07:00
Robert Lin
d7ab268385
feat/dotcom: add Enterprise Portal auth proxy (#63652)
Part of https://linear.app/sourcegraph/issue/CORE-211

This introduces authenticated proxies that allow dotcom site admins
access to dev and production Enterprise Portal instances, authenticated
with client credentials issued to the dotcom instance. The medium-term
goal is to use this proxy so that we can use the existing subscriptions
UI, backed by the new Enteprise Portal deployments (e.g.
https://github.com/sourcegraph/sourcegraph/pull/63653, tracking issue:
https://linear.app/sourcegraph/issue/CORE-100/enterprise-portal-migrate-away-from-dotcom-db-as-source-of-truth),
until we have a dedicated UI for Enterprise Portal
(https://linear.app/sourcegraph/project/kr-p-enterprise-portal-user-interface-dadd5ff28bd8)

This is required until we ship
https://linear.app/sourcegraph/project/kr-p1-streamlined-role-assignment-via-sams-and-entitle-2f118b3f9d4c/overview,
which will allow SAMS to be the source-of-truth for who is a site admin
in Sourcegraph.com. Once we have that information, we can use the user's
SAMS session directly in Enterprise Portal to authorize access to
Enterprise Portal data.

## Test plan

Set up `dev-private` with dev credentials:
https://github.com/sourcegraph/dev-private/pull/101

`sg start dotcom`, create a personal access token, and try to make
ConnectRPC requests matching the spec to the new endpoints:

```sh
# Local
curl --header "Content-Type: application/json" --header "authorization: token sgp_local_..." --data '{"filters":[{"filter":{"is_archived":false}}]}' -v  \
    https://sourcegraph.test:3443/.api/enterpriseportal/local/enterpriseportal.subscriptions.v1.SubscriptionsService/ListEnterpriseSubscriptions
# Dev
curl --header "Content-Type: application/json" --header "authorization: token sgp_local_..." --data '{"filters":[{"filter":{"is_archived":false}}]}' -v  \
    https://sourcegraph.test:3443/.api/enterpriseportal/dev/enterpriseportal.subscriptions.v1.SubscriptionsService/ListEnterpriseSubscriptions
```

Note that the URL path after `/.api/enterpriseportal/dev/`, i.e.
`/enterpriseportal.subscriptions.v1.SubscriptionsService/ListEnterpriseSubscriptions`,
and the shape of the parameters, are all the same as if you curl'd the
Enterprise Portal API directly, per the Connect protocol:
https://connectrpc.com/docs/protocol/

Both local and dev reach out to the existing SAMS dev deployment for
credentials, so the `dev-private` credentials work OOTB for both.

---------

Co-authored-by: Andre Eleuterio <andreeleuterio@users.noreply.github.com>
2024-07-09 13:46:59 -07:00
Felix Kling
160d1bf56d
chore(svelte): Update to latest cody web version (#63732)
Yet another PR to get cody web up-to-date in the new web app.

## Test plan
Manual testing.
2024-07-09 20:22:18 +00:00
Chris Smith
232cfcb097
Several refactoring to prepare for rolling out modelconfig (#63731)
This PR bundles several small refactoring to make it easier to review
the pending "refactor completion APIs to read from modelconfig".

Going commit-by-commit:

[Export the ValidateModelRef
function](3c949a88d0)

This just exports a validation function that was previously private from
the `internal/modelconfig` package. We'll be using this to sanity check
the `ModelRef` that is returned from the "getModelsFn".


[Add modelconfig.{InitMock,
ResetMock}](f807f40bf5)

In order to update the `frontend/internal/httpapi/completions` unit
tests, we need to have changes to the site configuration data _ALSO_
update the global `modelconfig.Service`. Typically this would happen by
a "config watcher" that gets registered, but we don't do that as part of
unit tests.

So instead, I just added some clunky `InitMock() error` and `ResetMock()
error` functions to support unit testing. If you have a better idea for
how to expose this behavior, I'm all ears.

[Move fireworks-specific API types into
types.go](bb02ccba45)

Moves the API data types for the `fireworks` client into their own file,
just to keep things tidy.

[Refactor completion
clients](02a5e3bfc9)

This is a bit involved, but from a high-level, we are just passing the
`types.CompletionRequest` object "lower" into the call stack. Rather
than only return the `.Parameters` field
(`types.CompletionRequestParameters`).

This is necessary, because I plan on adding another field to
`types.CompletionRequest` (to include the `modelconfig.Provider` and
`modelconfig.Model` data). So this change just does some of the work for
that now, resulting in a smaller and easier to review diff later.

Also, in some cases I moved the calls to
`tokenManager.UpdateTokenCountsFromModelUsage` into a dedicated function
to simplify the callsites.

## Test plan

Existing unit tests

## Changelog

NA
2024-07-09 13:16:36 -07:00
Erik Seliger
df4c636dc5
squirrel: Correctly use request context (#63729)
The ctx parameter was unused, and I noticed that the parser is called
without the request context. Fixing that here.

Test plan:

Code review and CI.
2024-07-09 22:06:01 +02:00
Camden Cheek
5d8286b90f
Backend: add line index (#63726)
This adds a line index utility. Frequently, I want to be able to
efficiently index a file to extract a specific line or range of lines,
but it's surprisingly tricky to get exactly right given weird
definitions of "what even is a line" and edge conditions around
out-of-bounds and such.

So this adds a general-purpose utility to pre-calculate the locations of
lines in the file, making extracting a line range a zero-allocation,
`O(1)` operation.

Not implemented: the same index can also be used to find the line that
contains an offset, which I've also needed to do before. But I'll save
that for when I actually have an immediate use for it.
2024-07-09 19:59:42 +00:00
Felix Kling
0fc4d2811a
feat(svelte): Add reblame support to blame column (#63727)
Closes srch-612

This commit adds a link next to the blame commit message that allows
reblaming to a prior commit if available.

It extends the existing blame extension. This won't have any affect on
the React app because it doesn't pass the configuration option needed to
add the extra gutter.

Some notes:

- I originally used the tooltip component instead of `title` but somehow
it starts to break when scrolling the document (tooltips don't show up
anymore). I don't know if CodeMirror does anything to the DOM elements
that causes this to fail.
- The reblame URL also selected the corresponding line so that the
correct line is scrolled into view.


## Test plan

Manual testing
2024-07-09 21:30:14 +02:00
Erik Seliger
fab128120d
searcher: Modernize entrypoint and gRPC server (#63700)
This PR does a bit of cleanup / alignment with other services, most
notably:

- Loads config via the config method of the shared routine package plus
tests for default config values
- Listens on HTTP using the existing httpserver package
- Makes it clear what gitserver methods are used by calling them at the
entry function instead of passing the whole client down
- Adds exhaustive request logging for better auditability (and found an
unused field which I removed)
- Rename log to logger
- Add the common stack of HTTP middlewares for actor, client etc
propagation

Test plan:

Unit tests still pass. CI is green and I was able to run unindexed
searches locally.
2024-07-09 21:10:11 +02:00
Stephen Gutekanst
071de9e33e
modelconfig: handle converting site config JSON -> internal data types (#63706)
This causes the `modelconfig` package to actually begin converting the
new `"modelConfiguration"` site config which was introduced in #63654
into the internal data types we use for model configuration.

This is all pretty straightforward / lame type conversion code, but
carefully written to preserve all the semantics we care about.

## Test plan

Written very carefully, and confirmed that this query:

```
curl -H "Authorization: token $(cat ~/local-token)" https://sourcegraph.test:3443/.api/modelconfig/supported-models.json
```

returns what I would expect with this site configuration:

<details>
<summary>site config</summary>

```
  // Setting this field means we are opting into the new Cody model configuration system which is in beta.
  "modelConfiguration": {
    // Disable use of Sourcegraph's servers for model discovery
    "sourcegraph": null,

    // Configure the OpenAI-compatible API endpoints that Cody should use to provide
    // mistral and bigcode (starcoder) models.
    "providerOverrides": [
      {
        "displayName": "Mistral",
        "id": "mistral",
        "serverSideConfig": {
          "type": "openaicompatible",
          "endpoint": "...",
          "accessToken": "...",
        },
      },
      {
        "displayName": "Bigcode",
        "id": "bigcode",
        "serverSideConfig": {
          "type": "openaicompatible",
          "endpoint": "...",
          "accessToken": "...",
        },
      },
    ],

    // Configure which exact mistral and starcoder models we want available
    "modelOverridesRecommendedSettings": [
      "bigcode::v1::starcoder2-7b",
      "mistral::v1::mixtral-8x7b-instruct"
    ],

    // Configure which models Cody will use by default
    "defaultModels": {
      "chat": "mistral::v1::mixtral-8x7b-instruct",
      "fastChat": "mistral::v1::mixtral-8x7b-instruct",
      "codeCompletion": "bigcode::v1::starcoder2-7b",
    }
  }
```

</details>

We could certainly use more unit tests here to prevent potential future
regressions, I can add those in a future PR.

## Changelog

Has no effect on users unless they opt into the early-access
`"modelConfiguration"` site config feature.

---------

Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
Co-authored-by: Chris Smith <chrsmith@users.noreply.github.com>
2024-07-09 11:40:32 -07:00
Matthew Manela
814aceb46f
feat(search): Make search aware of perforce changelist id mapping (#63563)
https://linear.app/sourcegraph/issue/SPLF-116/perforce-searching-by-perforce-changelist-id

## Details
We have had requests from our customers using Perforce to be able to
search inside of a changelist id. For a commit sha we support doing this

```
context:global repo:^perforce-sgdev-org/rhia-depot-test$@345c17c` some text
```

But for perforce they want to do the same thing but with the change list
ids. Which would look like this

```
context:global repo:^perforce-sgdev-org/rhia-depot-test$@changelist/83732` some text
```

To support this, I am attempting to smartly detect when we should do a
DB round trip and look up the proper mapping. I built a simple heuristic
that is
1. Is perforce changelist mapping feature flag enabled
2. Is this a perforce repo?
3. Is the revision request a integer ?

This mapping is just a best effort, if it fails it just falls back on
current behavior.

We are doing with a syntax of `@changelist/CL_ID` instead of supporting
`@CL_ID` to future proof us. This lookup focuses on finding the mapping
in the DB but in the future we may want to pre-create these refs in the
db duing mapping of perforce CLs to git commits.

## Limitations
This works well in testing however, the repo name@changelist/rev we
return contains the sha

![image](https://github.com/sourcegraph/sourcegraph/assets/304410/a673b9bd-d11f-4b36-bd95-c21ab8a5c4af)


I investigated changing this but it would required a larger change in
resolving the stream results. While that would be nice to have, I
decided to keep this minimal for now and add that later if needed

## Test plan

<!-- REQUIRED; info at
https://docs-legacy.sourcegraph.com/dev/background-information/testing_principles
-->

## Changelog
- For perforce depots, support searching within a specific changelist by
specifying a ref like `context:global repo:^repo/name$@changelist/83854`
2024-07-09 14:01:05 -04:00
Robert Lin
64ebfca904
fix/client/dev: update proxy overwrite to respect authProviders (#63624)
Closes https://linear.app/sourcegraph/issue/CORE-213

The existing overwrite stripping `window.context.authProviders` sourced
from a proxied API down to only built-in providers makes it impossible
to reliably run `sg start web-standalone` against Sourcegraph.com (and
likely other Sourcegraph instances). The docstring says:

> Only username/password auth-provider provider is supported with the
standalone server.

However, you _can_ log in with other OAuth2 providers locally, so it
doesn't make sense to remove them from the context. This PR removes the
overwrite so that we can log in to Sourcegraph.com with a locally
running web app, and talk to Cody and all that good stuff.

## How to log in to OAuth providers with `sg start web-standalone`

IIRC what happens:

1. Click "Sign in" -> go to OAuth2 provider -> log in
2. OAuth2 provider issues callback to the Sourcegraph instance, telling
it that you logged in
3. OAuth2 provider redirects you to the instance to confirm your session
- for SAMS in dotcom:

```
https://sourcegraph.com/.auth/callback?code=sams_ac_...
```

This redirect will surface an error, like so:

> Authentication failed. Try signing in again (and clearing cookies for
the current site). The error was: state parameter did not match the
expected value (possible request forgery).

This happens because you get redirected to an absolute URL, which will
be `sourcegraph.com` (the upstream Sourcegraph instance), which won't
match the cookie you get issued (`sourcegraph.test`). We just need to
make sure it matches and send the code to the callback through our local
proxy:

```diff
- https://sourcegraph.com/.auth/callback?code=sams_ac_...
+ https://sourcegraph.test:3443/.auth/callback?code=sams_ac_...
```

And everything will work :) I confirmed this works for e.g. logging into
S2 with GitHub as well, using the callback issued by GitHub.

We cannot make this the default behaviour, because the redirect URL is
usually configured in the OAuth provider. An example GitHub OAuth
application configuration:


![image](https://github.com/sourcegraph/sourcegraph/assets/23356519/c437cec4-f4e3-4915-acd9-b2002a55ce24)

Note their guidance on valid values:
https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/authorizing-oauth-apps#redirect-urls
- we must provide a single, absolute URL


This is very similar to the process used to log in to private Cloud
instances, e.g.
https://cloud-ops.sgdev.org/dashboard/environments/prod/instances/src-bd02273f6b90d1d1beee#log-in-to-the-instance-ui
(scroll to bottom of this section), which indicates we've thought about
similar cases before and found that this was the best way

## Test plan


https://www.loom.com/share/6cb3b3ca475b4b9392aa4b11938e76e6?sid=d99fcb59-4308-45c7-9f68-af9ac44c4e7e
2024-07-09 10:27:54 -07:00
Shivasurya
c3c706bc82
chore(security): Updated dind image to 27-0-3 (#63725)
<!-- PR description tips:
https://www.notion.so/sourcegraph/Write-a-good-pull-request-description-610a7fd3e613496eb76f450db5a49b6e
-->

Patches CVE-2024-24790 by upgrading to 27-0-3 tag. However, the patched
version has CVE-2024-24791 😟 and it doesnt have patch.

## Test plan

<!-- REQUIRED; info at
https://docs-legacy.sourcegraph.com/dev/background-information/testing_principles
-->
Build and test image locally.

### Instruction to build and test locally

- Go to `dev/oci_deps.bzl`
- Find the current tag example `docker:26.1.3-dind`
- Go to docker registry and search for updated tag and grab one example:
`docker:27.0.3-dind`
- docker pull --platform linux/amd64 docker:27.0.3-dind
- Add `platforms = ["linux/amd64"],` to the oci_pull for building and
testing locally
```bzl
  oci_pull(
        name = "upstream_dind_base",
        digest = "sha256:2632da0d24924b179adf1c2e6f4ea6fb866747e84baea6b2ffaa8bff982ce102",
        platforms = ["linux/amd64"],
    )
```
- Run `sg images build dind`
- For testing, run `docker run --rm -it --entrypoint /bin/sh -v
/var/run/docker.sock:/var/run/docker.sock dind:candidate`
- Test docker commands and pull and run image for testing

## Changelog

- Upgraded dind to 27.0.3 to patch CVE-2024-24790 vulnerability

<!-- OPTIONAL; info at
https://www.notion.so/sourcegraph/Writing-a-changelog-entry-dd997f411d524caabf0d8d38a24a878c
-->
2024-07-09 12:59:18 -04:00
William Bezuidenhout
767614bc68
chore(redis): set max active redis connections to 1000 (#63718)
When active client is 0, there is no limit to the amount of active
clients which can lead to Redis quickly reaching it's MaxClient (10000
by default)

For more context see [this slack
thread](https://sourcegraph.slack.com/archives/C05EMJM2SLR/p1720448507809479)

## Test plan
CI


## Changelog
* redis-pool: set max active clients to 1000
<!-- OPTIONAL; info at
https://www.notion.so/sourcegraph/Writing-a-changelog-entry-dd997f411d524caabf0d8d38a24a878c
-->
2024-07-09 18:21:51 +02:00
Michael Bahr
b28879a3e7
chore: reword headline from tokens to credentials (#63714)
Updates a headline to better reflect that we now use more than just
tokens.

## Test plan

Existing CI

## Changelog

<!-- OPTIONAL; info at
https://www.notion.so/sourcegraph/Writing-a-changelog-entry-dd997f411d524caabf0d8d38a24a878c
-->
2024-07-09 15:48:56 +00:00
Vova Kulikov
33d6a254c9
Cody Web: bump cody web to 0.2.3 (#63723)
Updating the `cody-web-experimental` package to the latest version which
- Fixed problems with telemetry (now we send agent level of telemetry
events with `Web.Cody` client name)
- Fixed remote repository context as you switch between chats 
- Added support for cody context filters in file and symbols mentions 
- Improved link rendering for remote files (no more "remote-file://"
protocol prefixes.

Also, this PR adds some missing CSS token overrides for the LLM picker
on dotcom.

Note: I, by accident, pushed the `0.2.2` version with the same build as
I have published already in `0.2.1`. NPM doesn't allow to override the
build with the same version, so I had to publish 0.2.3 to make it
through to the Sourcegraph repo. This is why we jump from 0.2.1 to 0.2.3

## Test plan
-General manual checks for Cody Web
2024-07-09 12:48:06 -03:00
Stefan Hengl
5021803d1d
update changelog: Keyword search GA (#63715)
Closes SPLF-125
2024-07-09 08:34:24 -07:00
Stefan Hengl
2ff4a84bd8
keyword search: remove beta badge (#63720)
This removes the beta badge from the CTA on the main page.

Closes SPLF-131
2024-07-09 08:24:31 -07:00
Jean-Hadrien Chabran
fea61ce01b
chore(local): sg analytics use the proper open wrapper (#63722)
We missed during the review that we are not using the `open` helper that
wraps using the right method depending on the OS, which means that `sg
analytics` doesn't work on Linux as is.

## Test plan

Locally tested.
2024-07-09 15:04:59 +00:00
Michael Bahr
62b0c89dbb
fix: better alignemnt of github credentials and check success notice (#63717)
Closes SRCH-701

Ideally we would use a DismissibleAlert one level up the React component
chain, but that's turning out too tricky for the time we have left:
https://sourcegraph.slack.com/archives/C07A21XEP0T/p1720486350310899

## Test plan

Manual testing

## Changelog

<!-- OPTIONAL; info at
https://www.notion.so/sourcegraph/Writing-a-changelog-entry-dd997f411d524caabf0d8d38a24a878c
-->
2024-07-09 15:02:25 +00:00
Michael Bahr
1261b06e36
fix: show success notice in the correct area (#63721)
Closes SRCH-706

Previously the success notice would appear in the commit signing area of
the site admin, even if we create a github app for regular code host
stuff. This PR fixes it.

It also udpates the partial storage key of the notice, so that it will
reappear if we create more apps.

## Test plan

Manual testing

## Changelog

<!-- OPTIONAL; info at
https://www.notion.so/sourcegraph/Writing-a-changelog-entry-dd997f411d524caabf0d8d38a24a878c
-->
2024-07-09 15:01:41 +00:00
William Bezuidenhout
5fd7947545
sg: when in CI we do not need to prompt for an identity (#63712)
There are cases when we use SG in CI and then we do not want to prompt
for identity

## Test plan
CI, unit tests and tested locally

## Changelog

<!-- OPTIONAL; info at
https://www.notion.so/sourcegraph/Writing-a-changelog-entry-dd997f411d524caabf0d8d38a24a878c
-->
2024-07-09 15:58:44 +02:00
Hitesh Sagtani
eb16d802a3
adding deepseek-v2 and deepseek fine-tuned model trained on symbol graph context (#63702)
## Context
1. Adds support for deepseek-coder-v2 model and added fine-tuned on
deepseek coder.

## Test plan
```
curl -vS -X POST http://localhost:9992/v1/completions/fireworks -H 'Authorization: bearer <SGD_TOKEN>' -d '{"stream":false,"max_tokens":50, "model": "fim-lang-specific-model-deepseek-stack-trained", "stop_sequences": ["\n\n"], "prompt": "const value = ", "stream":false, "languageId": "python"}' -H 'X-sourcegraph-feature: code_completions'
```

```
curl -vS -X POST http://localhost:9992/v1/completions/fireworks -H 'Authorization: bearer <SGD_TOKEN>' -d '{"stream":false,"max_tokens":50, "model": "fim-lang-specific-model-deepseek-logs-trained", "stop_sequences": ["\n\n"], "prompt": "const value = ", "stream":false, "languageId": "python"}' -H 'X-sourcegraph-feature: code_completions'
```
2024-07-09 17:57:16 +05:30
Anton Sviridov
6a88babae2
Syntactic indexing produce scip files (#63580)
Fixes GRAPH-695

The syntactic code intel worker now actually performs indexing of
repositories by piping the TAR archive stream from Gitserver straight
into scip-syntax CLI, and then manually invoking the upload enqueuer.


## Test plan

- New integration test verifying that indexing worker handles the
records correctly and uploads valid indexes

<!-- REQUIRED; info at
https://docs-legacy.sourcegraph.com/dev/background-information/testing_principles
-->

## Changelog

<!-- OPTIONAL; info at
https://www.notion.so/sourcegraph/Writing-a-changelog-entry-dd997f411d524caabf0d8d38a24a878c
-->
2024-07-09 13:49:55 +02:00
Bolaji Olajide
a33b7718aa
feat(batches): sign commits created using a GitHub app credential (#63707)
Closes SRCH-685

When a GitHub app credential is used to push a commit, the commits
aren't signed.
With this PR, we re-use the `DuplicateCommit` method to create a signed
commit so users who don't have a standalone Commit Signing app installed
still get a signed commit when the commit is created with a GitHub app.


![image](https://github.com/sourcegraph/sourcegraph/assets/25608335/3058d05c-c20d-495d-abdf-49d525ec1f43)

To avoid cyclic imports, I had to move the `AuthenticationStrategy`
const to the `internal/types` package and rename it to
`SourceAuthenticationStrategy` so it's clear.

## Test plan

Add a GitHub app as a credential, then create a changeset targeting the
repo that the GitHub app is installed on.
The final commit should be signed.

## Changelog

<!-- OPTIONAL; info at
https://www.notion.so/sourcegraph/Writing-a-changelog-entry-dd997f411d524caabf0d8d38a24a878c
-->
2024-07-09 06:17:34 -05:00
Michael Bahr
4e510a2fb2
chore: drop isGitHubApp field from batch changes credentials (#63709)
We now have the `gitHubApp` field that can be used instead.
`isGitHubApp` was only introduced as part of the batch changes
integration with github app, and is therefore not released yet.

Closes SRCH-704

## Test plan

Manual testing

## Changelog

<!-- OPTIONAL; info at
https://www.notion.so/sourcegraph/Writing-a-changelog-entry-dd997f411d524caabf0d8d38a24a878c
-->

---------

Co-authored-by: Bolaji Olajide <25608335+BolajiOlajide@users.noreply.github.com>
2024-07-09 13:01:33 +02:00
Noah S-C
e669330215
feat(sg): sqlite-backed local store for sg analytics (#63578)
Removes existing `sg analytics` command and replaces it with a
one-per-invocation sqlite backed approach. This is a local storage for
invocation events before theyre pushed to bigquery

## Test plan

```
sqlite> select * from analytics;
0190792e-af38-751a-b93e-8481290a18b6|1|{"args":[],"command":"sg help","flags":{"help":null,"sg":null},"nargs":0,"end_time":"2024-07-03T15:20:21.069837706Z","success":true}
0190792f-4e2b-7c35-98d6-ad73cab82391|1|{"args":["dotcom"],"command":"sg live","flags":{"live":null,"sg":null},"nargs":1,"end_time":"2024-07-03T15:21:04.563232429Z","success":true}
```

## Changelog

<!-- OPTIONAL; info at
https://www.notion.so/sourcegraph/Writing-a-changelog-entry-dd997f411d524caabf0d8d38a24a878c
-->

---------

Co-authored-by: William Bezuidenhout <william.bezuidenhout@sourcegraph.com>
2024-07-09 12:47:49 +02:00
Noah S-C
d9dff1191a
feat(sg): one-time oauth login to persist user email for analytics (#63603)
Uses OAuth flow to fetch user's email as a one-time action, persisting
it in ~/.sourcegraph/whoami.json. Flow is only re-attempted if that file
doesnt exist (failed to read) or if the email is empty.

Code yoinked and adapted from @nelsonjr 's code for `sg rfc` 🙏 


![image](https://github.com/sourcegraph/sourcegraph/assets/18282288/bfcd315b-dcbd-412d-a53c-86479c8475c7)

## Test plan

Tested locally, see screenshots above

## Changelog

<!-- OPTIONAL; info at
https://www.notion.so/sourcegraph/Writing-a-changelog-entry-dd997f411d524caabf0d8d38a24a878c
-->

---------

Co-authored-by: William Bezuidenhout <william.bezuidenhout@sourcegraph.com>
2024-07-09 12:07:17 +02:00