Skip to content

Commit d4be287

Browse files
authored
Update go to 1.25.5 and 1.24.11 in CI (#1433)
* Update go version to 1.25.5 and 1.24.11 in CI Signed-off-by: Cosmin Cojocar <[email protected]> * Update the buildSSA to use the new tools package Signed-off-by: Cosmin Cojocar <[email protected]> * Remove the type allignment check Signed-off-by: Cosmin Cojocar <[email protected]> --------- Signed-off-by: Cosmin Cojocar <[email protected]>
1 parent fde7515 commit d4be287

File tree

3 files changed

+56
-26
lines changed

3 files changed

+56
-26
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ jobs:
1111
strategy:
1212
matrix:
1313
version:
14-
- go-version: "1.24.10"
14+
- go-version: "1.24.11"
1515
golangci: "latest"
16-
- go-version: "1.25.4"
16+
- go-version: "1.25.5"
1717
golangci: "latest"
1818
runs-on: ubuntu-latest
1919
env:
@@ -52,7 +52,7 @@ jobs:
5252
- name: Setup go
5353
uses: actions/setup-go@v6
5454
with:
55-
go-version: "1.25.4"
55+
go-version: "1.25.5"
5656
- name: Checkout Source
5757
uses: actions/checkout@v6
5858
- uses: actions/cache@v4

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- name: Set up Go
1818
uses: actions/setup-go@v6
1919
with:
20-
go-version: "1.25.4"
20+
go-version: "1.25.5"
2121
- name: Install Cosign
2222
uses: sigstore/cosign-installer@v3
2323
with:

analyzer.go

Lines changed: 52 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ import (
3535

3636
"golang.org/x/tools/go/analysis"
3737
"golang.org/x/tools/go/analysis/passes/buildssa"
38+
"golang.org/x/tools/go/analysis/passes/ctrlflow"
39+
"golang.org/x/tools/go/analysis/passes/inspect"
3840
"golang.org/x/tools/go/packages"
3941

4042
"github.com/securego/gosec/v2/analyzers"
@@ -430,7 +432,7 @@ func (gosec *Analyzer) CheckAnalyzers(pkg *packages.Package) {
430432
buildssa.Analyzer: &analyzers.SSAAnalyzerResult{
431433
Config: gosec.Config(),
432434
Logger: gosec.logger,
433-
SSA: ssaResult.(*buildssa.SSA),
435+
SSA: ssaResult,
434436
},
435437
}
436438

@@ -491,7 +493,7 @@ func (gosec *Analyzer) generatedFiles(pkg *packages.Package) map[string]bool {
491493
}
492494

493495
// buildSSA runs the SSA pass which builds the SSA representation of the package. It handles gracefully any panic.
494-
func (gosec *Analyzer) buildSSA(pkg *packages.Package) (interface{}, error) {
496+
func (gosec *Analyzer) buildSSA(pkg *packages.Package) (*buildssa.SSA, error) {
495497
defer func() {
496498
if r := recover(); r != nil {
497499
gosec.logger.Printf(
@@ -500,26 +502,54 @@ func (gosec *Analyzer) buildSSA(pkg *packages.Package) (interface{}, error) {
500502
)
501503
}
502504
}()
503-
ssaPass := &analysis.Pass{
504-
Analyzer: buildssa.Analyzer,
505-
Fset: pkg.Fset,
506-
Files: pkg.Syntax,
507-
OtherFiles: pkg.OtherFiles,
508-
IgnoredFiles: pkg.IgnoredFiles,
509-
Pkg: pkg.Types,
510-
TypesInfo: pkg.TypesInfo,
511-
TypesSizes: pkg.TypesSizes,
512-
ResultOf: nil,
513-
Report: nil,
514-
ImportObjectFact: nil,
515-
ExportObjectFact: nil,
516-
ImportPackageFact: nil,
517-
ExportPackageFact: nil,
518-
AllObjectFacts: nil,
519-
AllPackageFacts: nil,
520-
}
521-
522-
return ssaPass.Analyzer.Run(ssaPass)
505+
if pkg == nil {
506+
return nil, errors.New("nil package provided")
507+
}
508+
if pkg.Types == nil {
509+
return nil, fmt.Errorf("package %s has no type information (compilation failed?)", pkg.Name)
510+
}
511+
if pkg.TypesInfo == nil {
512+
return nil, fmt.Errorf("package %s has no type information", pkg.Name)
513+
}
514+
pass := &analysis.Pass{
515+
Fset: pkg.Fset,
516+
Files: pkg.Syntax,
517+
OtherFiles: pkg.OtherFiles,
518+
IgnoredFiles: pkg.IgnoredFiles,
519+
Pkg: pkg.Types,
520+
TypesInfo: pkg.TypesInfo,
521+
TypesSizes: pkg.TypesSizes,
522+
ResultOf: make(map[*analysis.Analyzer]interface{}),
523+
Report: func(d analysis.Diagnostic) {},
524+
ImportObjectFact: func(obj types.Object, fact analysis.Fact) bool { return false },
525+
ExportObjectFact: func(obj types.Object, fact analysis.Fact) {},
526+
}
527+
528+
pass.Analyzer = inspect.Analyzer
529+
i, err := inspect.Analyzer.Run(pass)
530+
if err != nil {
531+
return nil, fmt.Errorf("running inspect analysis: %w", err)
532+
}
533+
pass.ResultOf[inspect.Analyzer] = i
534+
535+
pass.Analyzer = ctrlflow.Analyzer
536+
cf, err := ctrlflow.Analyzer.Run(pass)
537+
if err != nil {
538+
return nil, fmt.Errorf("running control flow analysis: %w", err)
539+
}
540+
pass.ResultOf[ctrlflow.Analyzer] = cf
541+
542+
pass.Analyzer = buildssa.Analyzer
543+
result, err := buildssa.Analyzer.Run(pass)
544+
if err != nil {
545+
return nil, fmt.Errorf("running SSA analysis: %w", err)
546+
}
547+
548+
ssaResult, ok := result.(*buildssa.SSA)
549+
if !ok {
550+
return nil, fmt.Errorf("unexpected SSA analysis result type: %T", result)
551+
}
552+
return ssaResult, nil
523553
}
524554

525555
// ParseErrors parses the errors from given package

0 commit comments

Comments
 (0)