Skip to content

Comments

Feat: Views and Views-Folders Resource/Data Source#393

Draft
OrNovo wants to merge 10 commits intomasterfrom
IAC-731
Draft

Feat: Views and Views-Folders Resource/Data Source#393
OrNovo wants to merge 10 commits intomasterfrom
IAC-731

Conversation

@OrNovo
Copy link
Contributor

@OrNovo OrNovo commented Jun 30, 2025

Description

Acceptance tests

  • Have you added an acceptance test for the functionality being added?
  • Have you run the acceptance tests on this branch?

Output from acceptance testing:

$ make testacc TESTARGS='-run=TestAccXXX'

...

Release Note

Release note for CHANGELOG:

...

References

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

@celaus celaus changed the title Iac 731 Feat: Views Resource/Data Source Jul 1, 2025
@OrNovo OrNovo changed the title Feat: Views Resource/Data Source Feat: Views and Views-Folders Resource/Data Source Jul 1, 2025
}

readReq := &cxsdk.GetViewRequest{
Id: wrapperspb.Int32(int32(id)),

Check failure

Code scanning / CodeQL

Incorrect conversion between integer types High

Incorrect conversion of an integer with architecture-dependent bit size from
strconv.Atoi
to a lower bit size type int32 without an upper bound check.

Copilot Autofix

AI 4 months ago

To fix this issue, we should add explicit upper and lower bounds checking before casting from int (returned from strconv.Atoi) to int32. If the parsed value falls outside the legal range for int32 (i.e., less than math.MinInt32 or greater than math.MaxInt32), we should return an appropriate error to the caller.

The best solution is to:

  1. Import the math package if not already present.
  2. After parsing the integer, check id < math.MinInt32 or id > math.MaxInt32.
  3. If outside the range, add an error to the diagnostics and return.
  4. Only do the cast to int32 if the bounds check passes.

All this needs to be done in internal/provider/data_exploration/resource_coralogix_view.go at/after lines 660-670.


Suggested changeset 1
internal/provider/data_exploration/resource_coralogix_view.go

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/internal/provider/data_exploration/resource_coralogix_view.go b/internal/provider/data_exploration/resource_coralogix_view.go
--- a/internal/provider/data_exploration/resource_coralogix_view.go
+++ b/internal/provider/data_exploration/resource_coralogix_view.go
@@ -18,6 +18,7 @@
 	"context"
 	"fmt"
 	"log"
+	"math"
 	"regexp"
 	"strconv"
 	"time"
@@ -665,6 +666,13 @@
 		)
 		return
 	}
+	if id < int(math.MinInt32) || id > int(math.MaxInt32) {
+		resp.Diagnostics.AddError(
+			"View ID Out of Range",
+			fmt.Sprintf("ID '%s' is outside of valid int32 range (%d to %d)", idStr, math.MinInt32, math.MaxInt32),
+		)
+		return
+	}
 
 	readReq := &cxsdk.GetViewRequest{
 		Id: wrapperspb.Int32(int32(id)),
EOF
@@ -18,6 +18,7 @@
"context"
"fmt"
"log"
"math"
"regexp"
"strconv"
"time"
@@ -665,6 +666,13 @@
)
return
}
if id < int(math.MinInt32) || id > int(math.MaxInt32) {
resp.Diagnostics.AddError(
"View ID Out of Range",
fmt.Sprintf("ID '%s' is outside of valid int32 range (%d to %d)", idStr, math.MinInt32, math.MaxInt32),
)
return
}

readReq := &cxsdk.GetViewRequest{
Id: wrapperspb.Int32(int32(id)),
Copilot is powered by AI and may make mistakes. Always verify output.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants