Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added terraform v14 support besides v12. #470

Merged
merged 2 commits into from
Jan 15, 2021

Conversation

devang-gaur
Copy link
Contributor

@devang-gaur devang-gaur commented Jan 13, 2021

PLEASE NOTE : Users will experience breaking changes while using Terraform 0.11 files, after this PR is merged.

Fixes #324

@codecov
Copy link

codecov bot commented Jan 13, 2021

Codecov Report

Merging #470 (a359304) into master (9ac1b32) will decrease coverage by 1.36%.
The diff coverage is 79.59%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #470      +/-   ##
==========================================
- Coverage   74.84%   73.48%   -1.37%     
==========================================
  Files          88       93       +5     
  Lines        2051     2074      +23     
==========================================
- Hits         1535     1524      -11     
- Misses        382      418      +36     
+ Partials      134      132       -2     
Impacted Files Coverage Δ
pkg/cli/run.go 91.17% <ø> (ø)
pkg/iac-providers/terraform/commons/convert.go 69.29% <ø> (ø)
.../iac-providers/terraform/commons/cty-converters.go 80.55% <ø> (ø)
...ac-providers/terraform/commons/local-references.go 3.33% <ø> (ø)
...c-providers/terraform/commons/lookup-references.go 76.00% <ø> (ø)
...iac-providers/terraform/commons/module-download.go 100.00% <ø> (ø)
...c-providers/terraform/commons/module-references.go 47.05% <ø> (ø)
pkg/iac-providers/terraform/commons/references.go 67.34% <ø> (ø)
pkg/iac-providers/terraform/commons/resource.go 66.66% <ø> (ø)
...providers/terraform/commons/variable-references.go 65.00% <ø> (ø)
... and 22 more

go.mod Outdated
@@ -1,31 +1,37 @@
module github.com/accurics/terrascan

go 1.15
go 1.14
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're moving to an earlier version of go?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops. fixed.

@@ -14,7 +14,7 @@
limitations under the License.
*/

package tfv12
package commons
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The package naming here may be misleading later on if breaking changes are introduced... These still depend on some HCL libs. If HCLv3 is added, or if we say need to support TF 0.11, I'm not sure this would fit. @kanchwala-yusuf --would it may make more sense to name this based on the HCL version supported? Does this portion of the code also depend on the tf version used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@williepaul why would be support tf 0.11 ? We'll support future versions right? And the way how golang doesn't allow to use multiple minor versions of a dependency simultaneously, I think we'll have to move with next future releases of terraform as well IMHO

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And this commons folder is inside iac-providers/terraform/. its not a general commons for all iac-providers.. So I think if we'll have to refactor things in future. It will not have impact outside of tf iac support

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@williepaul, let's keep it simple and straight forward and not try to future proof it. I think, commons package works, and it is within terraform package itself so shouldn't be harmful

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dev-gaur @kanchwala-yusuf I strongly disagree with the precedent--as a scanning tool, we should aim to scan IaC of all different versions and types. Why bother having an option to specify different versions, if we don't actually support different versions? Think from a user/customer perspective, because that's most important here. If a tool I am using to scan my files all of a sudden drops support for all my 1000 v12 IaC files I already have created, what do you think I'm going to do? Upgrade all of my IaC to v14, or find a tool that works with v12? The latter would be my first choice. Enterprise users are especially concerned about how often support is dropped. Sure, you can argue they can stick with older versions of the tool, but that brings in a separate maintenance issue for us as well, because situations can arise where we need to patch older versions (such as usage of old libraries that may have been affected by a vulnerability). Additionally, updating policies becomes another issue.

When it comes to tf11, in the commercial product, we support tf11, we have some customers using tf11, so supporting tf11 may not be just an option--it may be a requirement.

As far as the naming goes, it's not that big of a deal, but my thoughts are just that when new (and incompatible) versions are released, the "commons" name will be misleading...

@@ -43,7 +51,7 @@ func TestNewIacProvider(t *testing.T) {
{
name: "not supported iac type",
iacType: "not-supported",
iacVersion: terraformV12,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In our test code, rather than just changing all references from 12 to 14, is it possible to pass this as a parameter, then run it against multiple versions? While our code doesn't change, we just want to make sure our interaction with the library doesn't change when different versions are used either.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@@ -118,7 +118,7 @@ Flags:
-d, --iac-dir string path to a directory containing one or more IaC files (default ".")
-f, --iac-file string path to a single IaC file
-i, --iac-type string iac type (helm, k8s, kustomize, terraform)
--iac-version string iac version (helm: v3, k8s: v1, kustomize: v3, terraform: v12)
--iac-version string iac version (helm: v3, k8s: v1, kustomize: v3, terraform: v14)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are still supporting v12 as well, we should specify that in the help as well

@sonarcloud
Copy link

sonarcloud bot commented Jan 15, 2021

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 3 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@kanchwala-yusuf kanchwala-yusuf merged commit 49bf32d into tenable:master Jan 15, 2021
@amirbenv amirbenv linked an issue Jan 15, 2021 that may be closed by this pull request
devang-gaur pushed a commit to devang-gaur/terrascan that referenced this pull request Jan 18, 2021
kanchwala-yusuf added a commit that referenced this pull request Jan 18, 2021
cesar-rodriguez pushed a commit that referenced this pull request Jan 19, 2021
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.

terrascan doesn't allow registering multiple versions for an iac-type Support for Terraform v0.13
3 participants