Standardize NameWithOwner and Visible naming
Acronyms are now "NWO" and "Vis" respsectively
This commit is contained in:
@@ -22,11 +22,11 @@ func main() {
|
||||
}
|
||||
|
||||
// Migrate the schema: create the 'owner_repo' table from the struct
|
||||
err = db.AutoMigrate(&common.OwnerRepo{})
|
||||
err = db.AutoMigrate(&common.NameWithOwner{})
|
||||
if err != nil {
|
||||
panic("failed to migrate database")
|
||||
}
|
||||
|
||||
// Create an entry in the database
|
||||
db.Create(&common.OwnerRepo{Owner: "foo", Repo: "foo/bar"})
|
||||
db.Create(&common.NameWithOwner{Owner: "foo", Repo: "foo/bar"})
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ func (r *RunnerSingle) worker(wid int) {
|
||||
slog.Debug("Picking up job", "job", job, "worker", wid)
|
||||
|
||||
slog.Debug("Analysis: running", "job", job)
|
||||
storage.SetStatus(job.QueryPackId, job.ORepo, common.StatusQueued)
|
||||
storage.SetStatus(job.QueryPackId, job.NWO, common.StatusQueued)
|
||||
|
||||
resultFile, err := r.RunAnalysis(job)
|
||||
if err != nil {
|
||||
@@ -66,8 +66,8 @@ func (r *RunnerSingle) worker(wid int) {
|
||||
RunAnalysisBQRS: "", // FIXME ?
|
||||
}
|
||||
r.queue.Results() <- res
|
||||
storage.SetStatus(job.QueryPackId, job.ORepo, common.StatusSuccess)
|
||||
storage.SetResult(job.QueryPackId, job.ORepo, res)
|
||||
storage.SetStatus(job.QueryPackId, job.NWO, common.StatusSuccess)
|
||||
storage.SetResult(job.QueryPackId, job.NWO, res)
|
||||
|
||||
}
|
||||
}
|
||||
@@ -75,9 +75,9 @@ func (r *RunnerSingle) worker(wid int) {
|
||||
func (r *RunnerSingle) RunAnalysis(job common.AnalyzeJob) (string, error) {
|
||||
// TODO Add multi-language tests including queryLanguage
|
||||
// queryPackID, queryLanguage, dbOwner, dbRepo :=
|
||||
// job.QueryPackId, job.QueryLanguage, job.ORL.Owner, job.ORL.Repo
|
||||
// job.QueryPackId, job.QueryLanguage, job.NWO.Owner, job.NWO.Repo
|
||||
queryPackID, dbOwner, dbRepo :=
|
||||
job.QueryPackId, job.ORepo.Owner, job.ORepo.Repo
|
||||
job.QueryPackId, job.NWO.Owner, job.NWO.Repo
|
||||
|
||||
serverRoot := os.Getenv("MRVA_SERVER_ROOT")
|
||||
|
||||
@@ -135,7 +135,7 @@ func (r *RunnerSingle) RunAnalysis(job common.AnalyzeJob) (string, error) {
|
||||
|
||||
if err := cmd.Run(); err != nil {
|
||||
slog.Error("codeql database analyze failed:", "error", err, "job", job)
|
||||
storage.SetStatus(job.QueryPackId, job.ORepo, common.StatusError)
|
||||
storage.SetStatus(job.QueryPackId, job.NWO, common.StatusError)
|
||||
return "", err
|
||||
}
|
||||
|
||||
|
||||
@@ -1,24 +1,29 @@
|
||||
package common
|
||||
|
||||
type AnalyzeJob struct {
|
||||
MirvaRequestID int
|
||||
|
||||
QueryPackId int
|
||||
QueryLanguage string
|
||||
|
||||
ORepo OwnerRepo
|
||||
}
|
||||
|
||||
type OwnerRepo struct {
|
||||
// NameWithOwner represents a repository name and its owner name.
|
||||
type NameWithOwner struct {
|
||||
Owner string
|
||||
Repo string
|
||||
}
|
||||
|
||||
// AnalyzeJob represents a job specifying a repository and a query pack to analyze it with.
|
||||
// This is the message format that the agent receives from the queue.
|
||||
type AnalyzeJob struct {
|
||||
MRVARequestID int
|
||||
QueryPackId int
|
||||
QueryPackURL string
|
||||
QueryLanguage string
|
||||
NWO NameWithOwner
|
||||
}
|
||||
|
||||
// AnalyzeResult represents the result of an analysis job.
|
||||
// This is the message format that the agent sends to the queue.
|
||||
type AnalyzeResult struct {
|
||||
RunAnalysisSARIF string
|
||||
RunAnalysisBQRS string
|
||||
}
|
||||
|
||||
// Status represents the status of a job.
|
||||
type Status int
|
||||
|
||||
const (
|
||||
@@ -48,5 +53,5 @@ func (s Status) ToExternalString() string {
|
||||
|
||||
type JobSpec struct {
|
||||
JobID int
|
||||
OwnerRepo
|
||||
NameWithOwner
|
||||
}
|
||||
|
||||
@@ -57,10 +57,10 @@ func (s *StorageContainer) SaveQueryPack(tgz []byte, sessionID int) (storagePath
|
||||
return "todo:no-path-yet", nil
|
||||
}
|
||||
|
||||
func (s *StorageContainer) FindAvailableDBs(analysisReposRequested []common.OwnerRepo) (notFoundRepos []common.OwnerRepo, analysisRepos *map[common.OwnerRepo]qldbstore.DBLocation) {
|
||||
func (s *StorageContainer) FindAvailableDBs(analysisReposRequested []common.NameWithOwner) (notFoundRepos []common.NameWithOwner, analysisRepos *map[common.NameWithOwner]qldbstore.DBLocation) {
|
||||
// TODO s.FindAvailableDBs() via postgres
|
||||
analysisRepos = &map[common.OwnerRepo]qldbstore.DBLocation{}
|
||||
notFoundRepos = []common.OwnerRepo{}
|
||||
analysisRepos = &map[common.NameWithOwner]qldbstore.DBLocation{}
|
||||
notFoundRepos = []common.NameWithOwner{}
|
||||
|
||||
return notFoundRepos, analysisRepos
|
||||
}
|
||||
|
||||
@@ -8,6 +8,6 @@ import (
|
||||
type Storage interface {
|
||||
NextID() int
|
||||
SaveQueryPack(tgz []byte, sessionID int) (storagePath string, error error)
|
||||
FindAvailableDBs(analysisReposRequested []common.OwnerRepo) (not_found_repos []common.OwnerRepo,
|
||||
analysisRepos *map[common.OwnerRepo]qldbstore.DBLocation)
|
||||
FindAvailableDBs(analysisReposRequested []common.NameWithOwner) (not_found_repos []common.NameWithOwner,
|
||||
analysisRepos *map[common.NameWithOwner]qldbstore.DBLocation)
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
type Queue interface {
|
||||
Jobs() chan common.AnalyzeJob
|
||||
Results() chan common.AnalyzeResult
|
||||
StartAnalyses(analysis_repos *map[common.OwnerRepo]storage.DBLocation,
|
||||
StartAnalyses(analysis_repos *map[common.NameWithOwner]storage.DBLocation,
|
||||
session_id int,
|
||||
session_language string)
|
||||
}
|
||||
|
||||
@@ -14,19 +14,18 @@ func (q *QueueSingle) Results() chan common.AnalyzeResult {
|
||||
return q.results
|
||||
}
|
||||
|
||||
func (q *QueueSingle) StartAnalyses(analysis_repos *map[common.OwnerRepo]storage.DBLocation, session_id int,
|
||||
func (q *QueueSingle) StartAnalyses(analysis_repos *map[common.NameWithOwner]storage.DBLocation, session_id int,
|
||||
session_language string) {
|
||||
slog.Debug("Queueing codeql database analyze jobs")
|
||||
|
||||
for orl := range *analysis_repos {
|
||||
for nwo := range *analysis_repos {
|
||||
info := common.AnalyzeJob{
|
||||
QueryPackId: session_id,
|
||||
QueryLanguage: session_language,
|
||||
|
||||
ORepo: orl,
|
||||
NWO: nwo,
|
||||
}
|
||||
q.jobs <- info
|
||||
storage.SetStatus(session_id, orl, common.StatusQueued)
|
||||
storage.SetStatus(session_id, nwo, common.StatusQueued)
|
||||
storage.AddJob(session_id, info)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,33 +23,33 @@ import (
|
||||
|
||||
func (c *CommanderSingle) Setup(st *Visibles) {
|
||||
r := mux.NewRouter()
|
||||
c.st = st
|
||||
c.vis = st
|
||||
|
||||
//
|
||||
// First are the API endpoints that mirror those used in the github API
|
||||
//
|
||||
r.HandleFunc("/repos/{owner}/{repo}/code-scanning/codeql/variant-analyses", c.MirvaRequest)
|
||||
// /repos/hohn /mirva-controller/code-scanning/codeql/variant-analyses
|
||||
r.HandleFunc("/repos/{owner}/{repo}/code-scanning/codeql/variant-analyses", c.MRVARequest)
|
||||
// /repos/hohn /mrva-controller/code-scanning/codeql/variant-analyses
|
||||
// Or via
|
||||
r.HandleFunc("/{repository_id}/code-scanning/codeql/variant-analyses", c.MirvaRequestID)
|
||||
r.HandleFunc("/{repository_id}/code-scanning/codeql/variant-analyses", c.MRVARequestID)
|
||||
|
||||
r.HandleFunc("/", c.RootHandler)
|
||||
|
||||
// This is the standalone status request.
|
||||
// It's also the first request made when downloading; the difference is on the
|
||||
// client side's handling.
|
||||
r.HandleFunc("/repos/{owner}/{repo}/code-scanning/codeql/variant-analyses/{codeql_variant_analysis_id}", c.MirvaStatus)
|
||||
r.HandleFunc("/repos/{owner}/{repo}/code-scanning/codeql/variant-analyses/{codeql_variant_analysis_id}", c.MRVAStatus)
|
||||
|
||||
r.HandleFunc("/repos/{controller_owner}/{controller_repo}/code-scanning/codeql/variant-analyses/{codeql_variant_analysis_id}/repos/{repo_owner}/{repo_name}", c.MirvaDownloadArtifact)
|
||||
r.HandleFunc("/repos/{controller_owner}/{controller_repo}/code-scanning/codeql/variant-analyses/{codeql_variant_analysis_id}/repos/{repo_owner}/{repo_name}", c.MRVADownloadArtifact)
|
||||
|
||||
// Not implemented:
|
||||
// r.HandleFunc("/codeql-query-console/codeql-variant-analysis-repo-tasks/{codeql_variant_analysis_id}/{repo_id}/{owner_id}/{controller_repo_id}", MirvaDownLoad3)
|
||||
// r.HandleFunc("/github-codeql-query-console-prod/codeql-variant-analysis-repo-tasks/{codeql_variant_analysis_id}/{repo_id}", MirvaDownLoad4)
|
||||
// r.HandleFunc("/codeql-query-console/codeql-variant-analysis-repo-tasks/{codeql_variant_analysis_id}/{repo_id}/{owner_id}/{controller_repo_id}", MRVADownLoad3)
|
||||
// r.HandleFunc("/github-codeql-query-console-prod/codeql-variant-analysis-repo-tasks/{codeql_variant_analysis_id}/{repo_id}", MRVADownLoad4)
|
||||
|
||||
//
|
||||
// Now some support API endpoints
|
||||
//
|
||||
r.HandleFunc("/download-server/{local_path:.*}", c.MirvaDownloadServe)
|
||||
r.HandleFunc("/download-server/{local_path:.*}", c.MRVADownloadServe)
|
||||
|
||||
//
|
||||
// Bind to a port and pass our router in
|
||||
@@ -64,13 +64,13 @@ func (c *CommanderSingle) StatusResponse(w http.ResponseWriter, js common.JobSpe
|
||||
all_scanned := []common.ScannedRepo{}
|
||||
jobs := storage.GetJobList(js.JobID)
|
||||
for _, job := range jobs {
|
||||
astat := storage.GetStatus(js.JobID, job.ORepo).ToExternalString()
|
||||
astat := storage.GetStatus(js.JobID, job.NWO).ToExternalString()
|
||||
all_scanned = append(all_scanned,
|
||||
common.ScannedRepo{
|
||||
Repository: common.Repository{
|
||||
ID: 0,
|
||||
Name: job.ORepo.Repo,
|
||||
FullName: fmt.Sprintf("%s/%s", job.ORepo.Owner, job.ORepo.Repo),
|
||||
Name: job.NWO.Repo,
|
||||
FullName: fmt.Sprintf("%s/%s", job.NWO.Owner, job.NWO.Repo),
|
||||
Private: false,
|
||||
StargazersCount: 0,
|
||||
UpdatedAt: ji.UpdatedAt,
|
||||
@@ -82,7 +82,7 @@ func (c *CommanderSingle) StatusResponse(w http.ResponseWriter, js common.JobSpe
|
||||
)
|
||||
}
|
||||
|
||||
astat := storage.GetStatus(js.JobID, js.OwnerRepo).ToExternalString()
|
||||
astat := storage.GetStatus(js.JobID, js.NameWithOwner).ToExternalString()
|
||||
|
||||
status := common.StatusResponse{
|
||||
SessionId: js.JobID,
|
||||
@@ -116,9 +116,9 @@ func (c *CommanderSingle) RootHandler(w http.ResponseWriter, r *http.Request) {
|
||||
slog.Info("Request on /")
|
||||
}
|
||||
|
||||
func (c *CommanderSingle) MirvaStatus(w http.ResponseWriter, r *http.Request) {
|
||||
func (c *CommanderSingle) MRVAStatus(w http.ResponseWriter, r *http.Request) {
|
||||
vars := mux.Vars(r)
|
||||
slog.Info("mrva status request for ",
|
||||
slog.Info("MRVA status request for ",
|
||||
"owner", vars["owner"],
|
||||
"repo", vars["repo"],
|
||||
"codeql_variant_analysis_id", vars["codeql_variant_analysis_id"])
|
||||
@@ -142,8 +142,8 @@ func (c *CommanderSingle) MirvaStatus(w http.ResponseWriter, r *http.Request) {
|
||||
job := spec[0]
|
||||
|
||||
js := common.JobSpec{
|
||||
JobID: job.QueryPackId,
|
||||
OwnerRepo: job.ORepo,
|
||||
JobID: job.QueryPackId,
|
||||
NameWithOwner: job.NWO,
|
||||
}
|
||||
|
||||
ji := storage.GetJobInfo(js)
|
||||
@@ -152,7 +152,7 @@ func (c *CommanderSingle) MirvaStatus(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
// Download artifacts
|
||||
func (c *CommanderSingle) MirvaDownloadArtifact(w http.ResponseWriter, r *http.Request) {
|
||||
func (c *CommanderSingle) MRVADownloadArtifact(w http.ResponseWriter, r *http.Request) {
|
||||
vars := mux.Vars(r)
|
||||
slog.Info("MRVA artifact download",
|
||||
"controller_owner", vars["controller_owner"],
|
||||
@@ -170,7 +170,7 @@ func (c *CommanderSingle) MirvaDownloadArtifact(w http.ResponseWriter, r *http.R
|
||||
}
|
||||
js := common.JobSpec{
|
||||
JobID: vaid,
|
||||
OwnerRepo: common.OwnerRepo{
|
||||
NameWithOwner: common.NameWithOwner{
|
||||
Owner: vars["repo_owner"],
|
||||
Repo: vars["repo_name"],
|
||||
},
|
||||
@@ -181,7 +181,7 @@ func (c *CommanderSingle) MirvaDownloadArtifact(w http.ResponseWriter, r *http.R
|
||||
func (c *CommanderSingle) DownloadResponse(w http.ResponseWriter, js common.JobSpec, vaid int) {
|
||||
slog.Debug("Forming download response", "session", vaid, "job", js)
|
||||
|
||||
astat := storage.GetStatus(vaid, js.OwnerRepo)
|
||||
astat := storage.GetStatus(vaid, js.NameWithOwner)
|
||||
|
||||
var dlr common.DownloadResponse
|
||||
if astat == common.StatusSuccess {
|
||||
@@ -234,7 +234,7 @@ func (c *CommanderSingle) DownloadResponse(w http.ResponseWriter, js common.JobS
|
||||
|
||||
}
|
||||
|
||||
func (c *CommanderSingle) MirvaDownloadServe(w http.ResponseWriter, r *http.Request) {
|
||||
func (c *CommanderSingle) MRVADownloadServe(w http.ResponseWriter, r *http.Request) {
|
||||
vars := mux.Vars(r)
|
||||
slog.Info("File download request", "local_path", vars["local_path"])
|
||||
|
||||
@@ -266,16 +266,16 @@ func FileDownload(w http.ResponseWriter, path string) {
|
||||
|
||||
}
|
||||
|
||||
func (c *CommanderSingle) MirvaRequestID(w http.ResponseWriter, r *http.Request) {
|
||||
func (c *CommanderSingle) MRVARequestID(w http.ResponseWriter, r *http.Request) {
|
||||
vars := mux.Vars(r)
|
||||
slog.Info("New mrva using repository_id=%v\n", vars["repository_id"])
|
||||
}
|
||||
|
||||
func (c *CommanderSingle) MirvaRequest(w http.ResponseWriter, r *http.Request) {
|
||||
func (c *CommanderSingle) MRVARequest(w http.ResponseWriter, r *http.Request) {
|
||||
vars := mux.Vars(r)
|
||||
slog.Info("New mrva run ", "owner", vars["owner"], "repo", vars["repo"])
|
||||
|
||||
session_id := c.st.ServerStore.NextID()
|
||||
session_id := c.vis.ServerStore.NextID()
|
||||
session_owner := vars["owner"]
|
||||
session_controller_repo := vars["repo"]
|
||||
slog.Info("new run", "id: ", fmt.Sprint(session_id), session_owner, session_controller_repo)
|
||||
@@ -284,9 +284,9 @@ func (c *CommanderSingle) MirvaRequest(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
not_found_repos, analysisRepos := c.st.ServerStore.FindAvailableDBs(session_repositories)
|
||||
not_found_repos, analysisRepos := c.vis.ServerStore.FindAvailableDBs(session_repositories)
|
||||
|
||||
c.st.Queue.StartAnalyses(analysisRepos, session_id, session_language)
|
||||
c.vis.Queue.StartAnalyses(analysisRepos, session_id, session_language)
|
||||
|
||||
si := SessionInfo{
|
||||
ID: session_id,
|
||||
@@ -316,10 +316,10 @@ func (c *CommanderSingle) MirvaRequest(w http.ResponseWriter, r *http.Request) {
|
||||
w.Write(submit_response)
|
||||
}
|
||||
|
||||
func ORToArr(aor []common.OwnerRepo) ([]string, int) {
|
||||
func nwoToNwoStringArray(nwo []common.NameWithOwner) ([]string, int) {
|
||||
repos := []string{}
|
||||
count := len(aor)
|
||||
for _, repo := range aor {
|
||||
count := len(nwo)
|
||||
for _, repo := range nwo {
|
||||
repos = append(repos, fmt.Sprintf("%s/%s", repo.Owner, repo.Repo))
|
||||
}
|
||||
return repos, count
|
||||
@@ -330,17 +330,17 @@ func submit_response(sn SessionInfo) ([]byte, error) {
|
||||
var m_cr common.ControllerRepo
|
||||
var m_ac common.Actor
|
||||
|
||||
repos, count := ORToArr(sn.NotFoundRepos)
|
||||
repos, count := nwoToNwoStringArray(sn.NotFoundRepos)
|
||||
r_nfr := common.NotFoundRepos{RepositoryCount: count, RepositoryFullNames: repos}
|
||||
|
||||
repos, count = ORToArr(sn.AccessMismatchRepos)
|
||||
repos, count = nwoToNwoStringArray(sn.AccessMismatchRepos)
|
||||
r_amr := common.AccessMismatchRepos{RepositoryCount: count, Repositories: repos}
|
||||
|
||||
repos, count = ORToArr(sn.NoCodeqlDBRepos)
|
||||
repos, count = nwoToNwoStringArray(sn.NoCodeqlDBRepos)
|
||||
r_ncd := common.NoCodeqlDBRepos{RepositoryCount: count, Repositories: repos}
|
||||
|
||||
// TODO fill these with real values?
|
||||
repos, count = ORToArr(sn.NoCodeqlDBRepos)
|
||||
repos, count = nwoToNwoStringArray(sn.NoCodeqlDBRepos)
|
||||
r_olr := common.OverLimitRepos{RepositoryCount: count, Repositories: repos}
|
||||
|
||||
m_skip := common.SkippedRepositories{
|
||||
@@ -366,8 +366,8 @@ func submit_response(sn SessionInfo) ([]byte, error) {
|
||||
|
||||
for _, job := range joblist {
|
||||
storage.SetJobInfo(common.JobSpec{
|
||||
JobID: sn.ID,
|
||||
OwnerRepo: job.ORepo,
|
||||
JobID: sn.ID,
|
||||
NameWithOwner: job.NWO,
|
||||
}, common.JobInfo{
|
||||
QueryLanguage: sn.Language,
|
||||
CreatedAt: m_sr.CreatedAt,
|
||||
@@ -387,28 +387,28 @@ func submit_response(sn SessionInfo) ([]byte, error) {
|
||||
|
||||
}
|
||||
|
||||
func (c *CommanderSingle) collectRequestInfo(w http.ResponseWriter, r *http.Request, sessionId int) (string, []common.OwnerRepo, string, error) {
|
||||
func (c *CommanderSingle) collectRequestInfo(w http.ResponseWriter, r *http.Request, sessionId int) (string, []common.NameWithOwner, string, error) {
|
||||
slog.Debug("Collecting session info")
|
||||
|
||||
if r.Body == nil {
|
||||
err := errors.New("missing request body")
|
||||
log.Println(err)
|
||||
http.Error(w, err.Error(), http.StatusNoContent)
|
||||
return "", []common.OwnerRepo{}, "", err
|
||||
return "", []common.NameWithOwner{}, "", err
|
||||
}
|
||||
buf, err := io.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
var w http.ResponseWriter
|
||||
slog.Error("Error reading MRVA submission body", "error", err.Error())
|
||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||
return "", []common.OwnerRepo{}, "", err
|
||||
return "", []common.NameWithOwner{}, "", err
|
||||
}
|
||||
msg, err := TrySubmitMsg(buf)
|
||||
if err != nil {
|
||||
// Unknown message
|
||||
slog.Error("Unknown MRVA submission body format")
|
||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||
return "", []common.OwnerRepo{}, "", err
|
||||
return "", []common.NameWithOwner{}, "", err
|
||||
}
|
||||
// Decompose the SubmitMsg and keep information
|
||||
|
||||
@@ -417,19 +417,19 @@ func (c *CommanderSingle) collectRequestInfo(w http.ResponseWriter, r *http.Requ
|
||||
slog.Error("MRVA submission body querypack has invalid format")
|
||||
err := errors.New("MRVA submission body querypack has invalid format")
|
||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||
return "", []common.OwnerRepo{}, "", err
|
||||
return "", []common.NameWithOwner{}, "", err
|
||||
}
|
||||
session_tgz_ref, err := c.extract_tgz(msg.QueryPack, sessionId)
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||
return "", []common.OwnerRepo{}, "", err
|
||||
return "", []common.NameWithOwner{}, "", err
|
||||
}
|
||||
|
||||
// 2. Save the language
|
||||
session_language := msg.Language
|
||||
|
||||
// 3. Save the repositories
|
||||
var session_repositories []common.OwnerRepo
|
||||
var session_repositories []common.NameWithOwner
|
||||
|
||||
for _, v := range msg.Repositories {
|
||||
t := strings.Split(v, "/")
|
||||
@@ -439,7 +439,7 @@ func (c *CommanderSingle) collectRequestInfo(w http.ResponseWriter, r *http.Requ
|
||||
http.Error(w, err, http.StatusBadRequest)
|
||||
}
|
||||
session_repositories = append(session_repositories,
|
||||
common.OwnerRepo{Owner: t[0], Repo: t[1]})
|
||||
common.NameWithOwner{Owner: t[0], Repo: t[1]})
|
||||
}
|
||||
return session_language, session_repositories, session_tgz_ref, nil
|
||||
}
|
||||
@@ -492,7 +492,7 @@ func (c *CommanderSingle) extract_tgz(qp string, sessionID int) (string, error)
|
||||
return "", err
|
||||
}
|
||||
|
||||
session_query_pack_tgz_filepath, err := c.st.ServerStore.SaveQueryPack(tgz, sessionID)
|
||||
session_query_pack_tgz_filepath, err := c.vis.ServerStore.SaveQueryPack(tgz, sessionID)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
@@ -15,18 +15,18 @@ type SessionInfo struct {
|
||||
|
||||
QueryPack string
|
||||
Language string
|
||||
Repositories []common.OwnerRepo
|
||||
Repositories []common.NameWithOwner
|
||||
|
||||
AccessMismatchRepos []common.OwnerRepo
|
||||
NotFoundRepos []common.OwnerRepo
|
||||
NoCodeqlDBRepos []common.OwnerRepo
|
||||
OverLimitRepos []common.OwnerRepo
|
||||
AccessMismatchRepos []common.NameWithOwner
|
||||
NotFoundRepos []common.NameWithOwner
|
||||
NoCodeqlDBRepos []common.NameWithOwner
|
||||
OverLimitRepos []common.NameWithOwner
|
||||
|
||||
AnalysisRepos *map[common.OwnerRepo]storage.DBLocation
|
||||
AnalysisRepos *map[common.NameWithOwner]storage.DBLocation
|
||||
}
|
||||
|
||||
type CommanderSingle struct {
|
||||
st *Visibles
|
||||
vis *Visibles
|
||||
}
|
||||
|
||||
func NewCommanderSingle() *CommanderSingle {
|
||||
|
||||
@@ -24,10 +24,10 @@ func (s *StorageContainer) SaveQueryPack(tgz []byte, sessionID int) (storagePath
|
||||
return "todo:no-path-yet", nil
|
||||
}
|
||||
|
||||
func (s *StorageContainer) FindAvailableDBs(analysisReposRequested []common.OwnerRepo) (notFoundRepos []common.OwnerRepo, analysisRepos *map[common.OwnerRepo]DBLocation) {
|
||||
func (s *StorageContainer) FindAvailableDBs(analysisReposRequested []common.NameWithOwner) (notFoundRepos []common.NameWithOwner, analysisRepos *map[common.NameWithOwner]DBLocation) {
|
||||
// TODO s.FindAvailableDBs() via postgres
|
||||
analysisRepos = &map[common.OwnerRepo]DBLocation{}
|
||||
notFoundRepos = []common.OwnerRepo{}
|
||||
analysisRepos = &map[common.NameWithOwner]DBLocation{}
|
||||
notFoundRepos = []common.NameWithOwner{}
|
||||
|
||||
return notFoundRepos, analysisRepos
|
||||
}
|
||||
|
||||
@@ -5,6 +5,6 @@ import "mrvacommander/pkg/common"
|
||||
type Storage interface {
|
||||
NextID() int
|
||||
SaveQueryPack(tgz []byte, sessionID int) (storagePath string, error error)
|
||||
FindAvailableDBs(analysisReposRequested []common.OwnerRepo) (not_found_repos []common.OwnerRepo,
|
||||
analysisRepos *map[common.OwnerRepo]DBLocation)
|
||||
FindAvailableDBs(analysisReposRequested []common.NameWithOwner) (not_found_repos []common.NameWithOwner,
|
||||
analysisRepos *map[common.NameWithOwner]DBLocation)
|
||||
}
|
||||
|
||||
@@ -67,8 +67,8 @@ func (s *StorageSingle) SaveQueryPack(tgz []byte, sessionId int) (string, error)
|
||||
// Determine for which repositories codeql databases are available.
|
||||
//
|
||||
// Those will be the analysis_repos. The rest will be skipped.
|
||||
func (s *StorageSingle) FindAvailableDBs(analysisReposRequested []common.OwnerRepo) (not_found_repos []common.OwnerRepo,
|
||||
analysisRepos *map[common.OwnerRepo]DBLocation) {
|
||||
func (s *StorageSingle) FindAvailableDBs(analysisReposRequested []common.NameWithOwner) (not_found_repos []common.NameWithOwner,
|
||||
analysisRepos *map[common.NameWithOwner]DBLocation) {
|
||||
slog.Debug("Looking for available CodeQL databases")
|
||||
|
||||
cwd, err := os.Getwd()
|
||||
@@ -77,9 +77,9 @@ func (s *StorageSingle) FindAvailableDBs(analysisReposRequested []common.OwnerRe
|
||||
return
|
||||
}
|
||||
|
||||
analysisRepos = &map[common.OwnerRepo]DBLocation{}
|
||||
analysisRepos = &map[common.NameWithOwner]DBLocation{}
|
||||
|
||||
not_found_repos = []common.OwnerRepo{}
|
||||
not_found_repos = []common.NameWithOwner{}
|
||||
|
||||
for _, rep := range analysisReposRequested {
|
||||
dbPrefix := filepath.Join(cwd, "codeql", "dbs", rep.Owner, rep.Repo)
|
||||
@@ -110,7 +110,7 @@ func ArtifactURL(js common.JobSpec, vaid int) (string, error) {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
zfpath, err := PackageResults(ar, js.OwnerRepo, vaid)
|
||||
zfpath, err := PackageResults(ar, js.NameWithOwner, vaid)
|
||||
if err != nil {
|
||||
slog.Error("Error packaging results:", "error", err)
|
||||
return "", err
|
||||
@@ -129,13 +129,13 @@ func GetResult(js common.JobSpec) common.AnalyzeResult {
|
||||
return ar
|
||||
}
|
||||
|
||||
func SetResult(sessionid int, orl common.OwnerRepo, ar common.AnalyzeResult) {
|
||||
func SetResult(sessionid int, orl common.NameWithOwner, ar common.AnalyzeResult) {
|
||||
mutex.Lock()
|
||||
defer mutex.Unlock()
|
||||
result[common.JobSpec{JobID: sessionid, OwnerRepo: orl}] = ar
|
||||
result[common.JobSpec{JobID: sessionid, NameWithOwner: orl}] = ar
|
||||
}
|
||||
|
||||
func PackageResults(ar common.AnalyzeResult, owre common.OwnerRepo, vaid int) (zipPath string, e error) {
|
||||
func PackageResults(ar common.AnalyzeResult, owre common.NameWithOwner, vaid int) (zipPath string, e error) {
|
||||
slog.Debug("Readying zip file with .sarif/.bqrs", "analyze-result", ar)
|
||||
|
||||
cwd, err := os.Getwd()
|
||||
@@ -210,10 +210,10 @@ func SetJobInfo(js common.JobSpec, ji common.JobInfo) {
|
||||
info[js] = ji
|
||||
}
|
||||
|
||||
func GetStatus(sessionid int, orl common.OwnerRepo) common.Status {
|
||||
func GetStatus(sessionid int, orl common.NameWithOwner) common.Status {
|
||||
mutex.Lock()
|
||||
defer mutex.Unlock()
|
||||
return status[common.JobSpec{JobID: sessionid, OwnerRepo: orl}]
|
||||
return status[common.JobSpec{JobID: sessionid, NameWithOwner: orl}]
|
||||
}
|
||||
|
||||
func ResultAsFile(path string) (string, []byte, error) {
|
||||
@@ -231,10 +231,10 @@ func ResultAsFile(path string) (string, []byte, error) {
|
||||
return fpath, file, nil
|
||||
}
|
||||
|
||||
func SetStatus(sessionid int, orl common.OwnerRepo, s common.Status) {
|
||||
func SetStatus(sessionid int, orl common.NameWithOwner, s common.Status) {
|
||||
mutex.Lock()
|
||||
defer mutex.Unlock()
|
||||
status[common.JobSpec{JobID: sessionid, OwnerRepo: orl}] = s
|
||||
status[common.JobSpec{JobID: sessionid, NameWithOwner: orl}] = s
|
||||
}
|
||||
|
||||
func AddJob(sessionid int, job common.AnalyzeJob) {
|
||||
|
||||
Reference in New Issue
Block a user