/
githubmirror
/
gitness
Обзор
Документация
Войти
/
githubmirror
/
gitness
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
app/api/controller/repo/get_commit.go
55 строк
2 KB
Atefeh Mohseni Ejiyeh
feat: [CODE-2549] verify signature on individual commit API (#5172)
14 апр 2026, 18:12
14 апр 2026, 18:12
2e49ff6
Код
Авторство
О чём код?
// Copyright 2023 Harness, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package repo import ( "context" "fmt" "github.com/harness/gitness/app/api/controller" "github.com/harness/gitness/app/auth" "github.com/harness/gitness/git" "github.com/harness/gitness/types" "github.com/harness/gitness/types/enum" ) // GetCommit gets a repo commit. func (c *Controller) GetCommit(ctx context.Context, session *auth.Session, repoRef string, rev string, ) (*types.Commit, error) { repo, err := c.getRepoCheckAccess(ctx, session, repoRef, enum.PermissionRepoView) if err != nil { return nil, err } rpcOut, err := c.git.GetCommit(ctx, &git.GetCommitParams{ ReadParams: git.CreateReadParams(repo), Revision: rev, }) if err != nil { return nil, fmt.Errorf("failed to get commit: %w", err) } commit := controller.MapCommit(&rpcOut.Commit) err = c.signatureVerifyService.VerifyCommits(ctx, repo.ID, []*types.Commit{commit}) if err != nil { return nil, fmt.Errorf("failed to verify signature of commit: %w", err) } return commit, nil }