Compare commits

..

1 Commits

Author SHA1 Message Date
dependabot[bot]
ac82971faa build(deps): bump github/codeql-action from 4.35.3 to 4.36.2
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 4.35.3 to 4.36.2.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](e46ed2cbd0...8aad20d150)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: 4.36.2
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-06-25 04:12:30 +00:00
4 changed files with 18 additions and 44 deletions

View File

@@ -54,14 +54,14 @@ jobs:
restore-keys: go-artifacts-${{ runner.os }}-codeql-analyze-${{ steps.go.outputs.go-version }}-
- name: Initialize CodeQL
uses: github/codeql-action/init@e46ed2cbd01164d986452f91f178727624ae40d7 # v4.35.3
uses: github/codeql-action/init@8aad20d150bbac5944a9f9d289da16a4b0d87c1e # v4.36.2
with:
languages: go
- name: Autobuild
uses: github/codeql-action/autobuild@e46ed2cbd01164d986452f91f178727624ae40d7 # v4.35.3
uses: github/codeql-action/autobuild@8aad20d150bbac5944a9f9d289da16a4b0d87c1e # v4.36.2
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@e46ed2cbd01164d986452f91f178727624ae40d7 # v4.35.3
uses: github/codeql-action/analyze@8aad20d150bbac5944a9f9d289da16a4b0d87c1e # v4.36.2
with:
category: 'language:go'

View File

@@ -236,11 +236,11 @@ func NewAlertAPI(ar *AlertingRule, a *notifier.Alert) *ApiAlert {
return aa
}
func (r *ApiRule) ExtendState(normalizeAlertState bool) {
if !normalizeAlertState && len(r.Alerts) > 0 {
func (r *ApiRule) ExtendState() {
if len(r.Alerts) > 0 {
return
}
if r.State == "" || r.State == "inactive" || r.State == "pending" || r.State == "firing" {
if r.State == "" {
r.State = "ok"
}
if r.Health != "ok" {

View File

@@ -54,26 +54,6 @@ func TestRecordingToApi(t *testing.T) {
}
}
func TestApiRuleExtendStateForWeb(t *testing.T) {
seriesFetched := 1
r := ApiRule{
State: "firing",
Health: "ok",
LastSeriesFetched: &seriesFetched,
Alerts: []*ApiAlert{{State: "firing"}},
}
r.ExtendState(false)
if r.State != "firing" {
t.Fatalf("expected alert rule state to expect %q; got %q", "firing", r.State)
}
r.ExtendState(true)
if r.State != "ok" {
t.Fatalf("expected alert rule state to expect %q; got %q", "ok", r.State)
}
}
func TestURLValuesToStrings(t *testing.T) {
mapQueryParams := map[string][]string{
"param1": {"param1"},

View File

@@ -122,9 +122,6 @@ func (rh *requestHandler) handler(w http.ResponseWriter, r *http.Request) bool {
httpserver.Errorf(w, r, "%s", err)
return true
}
if r.URL.Path == "/vmalert/groups" {
rf.normalizeAlertState = true
}
// only support filtering by a single state
state := ""
if len(rf.states) > 0 {
@@ -374,17 +371,16 @@ func newAlertsFilter(r *http.Request) (*alertsFilter, *httpserver.ErrorWithStatu
// see https://prometheus.io/docs/prometheus/latest/querying/api/#rules
type rulesFilter struct {
gf *groupsFilter
ruleNames []string
ruleType string
excludeAlerts bool
states []string
maxGroups int
pageNum int
search string
match [][]metricsql.LabelFilter
extendedStates bool
normalizeAlertState bool
gf *groupsFilter
ruleNames []string
ruleType string
excludeAlerts bool
states []string
maxGroups int
pageNum int
search string
match [][]metricsql.LabelFilter
extendedStates bool
}
func newRulesFilter(r *http.Request) (*rulesFilter, *httpserver.ErrorWithStatusCode) {
@@ -547,10 +543,8 @@ func (rh *requestHandler) groups(rf *rulesFilter) *listGroupsResponse {
if !groupFound && !strings.Contains(strings.ToLower(rule.Name), rf.search) {
continue
}
ruleWithExtendedState := rule
ruleWithExtendedState.ExtendState(rf.normalizeAlertState)
if rf.extendedStates {
rule = ruleWithExtendedState
rule.ExtendState()
}
if !rf.matchesRule(&rule) {
continue
@@ -558,7 +552,7 @@ func (rh *requestHandler) groups(rf *rulesFilter) *listGroupsResponse {
if rf.excludeAlerts {
rule.Alerts = nil
}
g.States[ruleWithExtendedState.State]++
g.States[rule.State]++
filteredRules = append(filteredRules, rule)
}
if len(g.Rules) == 0 || len(filteredRules) > 0 {