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

✨ adds USER instruction to Dockerfile #3937

Merged
merged 4 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cli/reporter/cnquery_report.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion explorer/cnquery_explorer.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion explorer/resources/cnquery_resources_explorer.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion explorer/scan/cnquery_explorer_scan.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion llx/llx.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion providers-sdk/v1/inventory/inventory.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion providers-sdk/v1/plugin/plugin.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion providers-sdk/v1/resources/resources.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion providers-sdk/v1/upstream/health/errors.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion providers-sdk/v1/upstream/health/health.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion providers-sdk/v1/upstream/mvd/cvss/cvss.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion providers-sdk/v1/upstream/mvd/mvd.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion providers-sdk/v1/upstream/upstream.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion providers-sdk/v1/vault/vault.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 14 additions & 11 deletions providers/azure/resources/azure.lr.manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@ resources:
name:
- azure
azure.subscription:
refs:
- title: Subscriptions, licenses, accounts, and tenants for Microsoft's cloud offerings
url: https://learn.microsoft.com/en-us/microsoft-365/enterprise/subscriptions-licenses-accounts-and-tenants-for-microsoft-cloud-offerings
docs:
desc: Use the `azure.subscription` resource to assess the configuration of Azure subscriptions.
desc: Use the `azure.subscription` resource to assess the configuration of Azure
subscriptions.
fields:
advisor: {}
aks: {}
Expand Down Expand Up @@ -45,12 +43,17 @@ resources:
platform:
name:
- azure
refs:
- title: Subscriptions, licenses, accounts, and tenants for Microsoft's cloud
offerings
url: https://learn.microsoft.com/en-us/microsoft-365/enterprise/subscriptions-licenses-accounts-and-tenants-for-microsoft-cloud-offerings
snippets:
- query: "azure.subscription {\n subscriptionId \n managedByTenants\n}\n"
title: Return the subscription ID and a list of tenants that manage the subscription
azure.subscription.advisor:
docs:
desc: Use the `azure.subscription.advisor` resource to retrieve scoring and recommendations from Microsoft Azure Advisor.
desc: Use the `azure.subscription.advisor` resource to retrieve scoring and
recommendations from Microsoft Azure Advisor.
fields:
recommendations: {}
subscriptionId: {}
Expand Down Expand Up @@ -197,11 +200,6 @@ resources:
- query: "azure.subscription.aks.clusters {\n id \n createdAt \n powerState \n}\n"
title: Return the ID, date and time created, and current power state of clusters
azure.subscription.aksService:
refs:
- title: What is Azure Kubernetes Service (AKS)?
url: https://learn.microsoft.com/en-us/azure/aks/what-is-aks
- title: Azure Kubernetes Service (AKS) documentation
url: https://learn.microsoft.com/en-us/azure/aks/
fields:
clusters: {}
subscriptionId: {}
Expand All @@ -210,12 +208,12 @@ resources:
platform:
name:
- azure
azure.subscription.aksService.cluster:
refs:
- title: What is Azure Kubernetes Service (AKS)?
url: https://learn.microsoft.com/en-us/azure/aks/what-is-aks
- title: Azure Kubernetes Service (AKS) documentation
url: https://learn.microsoft.com/en-us/azure/aks/
azure.subscription.aksService.cluster:
fields:
addonProfiles: {}
agentPoolProfiles: {}
Expand All @@ -242,6 +240,11 @@ resources:
platform:
name:
- azure
refs:
- title: What is Azure Kubernetes Service (AKS)?
url: https://learn.microsoft.com/en-us/azure/aks/what-is-aks
- title: Azure Kubernetes Service (AKS) documentation
url: https://learn.microsoft.com/en-us/azure/aks/
azure.subscription.authorization:
fields:
roleDefinitions: {}
Expand Down
28 changes: 28 additions & 0 deletions providers/os/resources/docker_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ func (p *mqlDockerFile) stage2resource(stage instructions.Stage) (*mqlDockerFile
var unsupported []string
var entrypointRaw *instructions.EntrypointCommand
var cmdRaw *instructions.CmdCommand
var userRaw *instructions.UserCommand
for i := range stage.Commands {
switch v := stage.Commands[i].(type) {
case *instructions.EnvCommand:
Expand All @@ -188,6 +189,9 @@ func (p *mqlDockerFile) stage2resource(stage instructions.Stage) (*mqlDockerFile
for _, kv := range v.Labels {
labels[kv.Key] = kv.Value
}
case *instructions.UserCommand:
userRaw = v

case *instructions.RunCommand:
script := strings.Join(v.ShellDependantCmdLine.CmdLine, "\n")
runResource, err := CreateResource(p.MqlRuntime, "docker.file.run", map[string]*llx.RawData{
Expand Down Expand Up @@ -312,6 +316,30 @@ func (p *mqlDockerFile) stage2resource(stage instructions.Stage) (*mqlDockerFile
args["cmd"] = llx.NilData
}

if userRaw != nil {
arr := strings.Split(userRaw.User, ":")
var user string
var group string
if len(arr) != 0 && arr[0] != "" {
user = arr[0]
}

if len(arr) > 1 && arr[1] != "" {
group = arr[1]
}
userResource, err := CreateResource(p.MqlRuntime, "docker.file.user", map[string]*llx.RawData{
"__id": llx.StringData(p.locationID(userRaw.Location())),
"user": llx.StringData(user),
"group": llx.StringData(group),
})
if err != nil {
return nil, err
}
args["user"] = llx.ResourceData(userResource, "docker.file.user")
} else {
args["user"] = llx.NilData
}

rawStage, err := CreateResource(p.MqlRuntime, "docker.file.stage", args)
if err != nil {
return nil, err
Expand Down
Loading
Loading