Skip to content

Commit

Permalink
Fix typos in errors, help, and code comments (#1717)
Browse files Browse the repository at this point in the history
  • Loading branch information
tas50 authored Sep 13, 2023
1 parent 9c33340 commit a08097d
Show file tree
Hide file tree
Showing 31 changed files with 52 additions and 52 deletions.
4 changes: 2 additions & 2 deletions _motor/discovery/k8s/list_nodes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func TestListNodesAKS(t *testing.T) {
require.ElementsMatch(t, []string{"k8s"}, assets[0].Platform.Family)
require.Equal(t, []string{"//platformid.api.mondoo.app/runtime/k8s/uid/e26043bb-8669-48a2-b684-b1e132198cdc/nodes/name/aks-default-36939070-vmss000000"}, assets[0].PlatformIds)

// Adds relatonship to host
// Adds relationship to host
require.Len(t, assets[0].RelatedAssets, 1)
require.Equal(t, "aks-default-36939070-vmss000000", assets[0].RelatedAssets[0].Name)
require.Equal(t, providers.Kind_KIND_VIRTUAL_MACHINE, assets[0].RelatedAssets[0].Platform.Kind)
Expand Down Expand Up @@ -309,7 +309,7 @@ func TestListNodesK3S(t *testing.T) {
require.ElementsMatch(t, []string{"k8s"}, assets[0].Platform.Family)
require.Equal(t, []string{"//platformid.api.mondoo.app/runtime/k8s/uid/e26043bb-8669-48a2-b684-b1e132198cdc/nodes/name/x1"}, assets[0].PlatformIds)

// Adds relatonship to host
// Adds relationship to host
require.Len(t, assets[0].RelatedAssets, 1)
require.Equal(t, "x1", assets[0].RelatedAssets[0].Name)
require.Equal(t, providers.Kind_KIND_UNKNOWN, assets[0].RelatedAssets[0].GetPlatform().GetKind())
Expand Down
6 changes: 3 additions & 3 deletions _motor/discovery/k8s/list_workloads_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1645,15 +1645,15 @@ func TestListFiltering(t *testing.T) {
// List w/glob 'kube*'
assets, err = ListPods(p, pCfg, clusterIdentifier, NamespaceFilterOpts{include: []string{"kube*"}}, make(map[string][]K8sResourceIdentifier), ownershipDir)
require.NoError(t, err)
assert.Equal(t, 4, len(assets), "expected 4 Pods to be returned from matched Namspaces")
assert.Equal(t, 4, len(assets), "expected 4 Pods to be returned from matched Namespaces")

// List w/glob '*alt*'
assets, err = ListPods(p, pCfg, clusterIdentifier, NamespaceFilterOpts{include: []string{"*alt*"}}, make(map[string][]K8sResourceIdentifier), ownershipDir)
require.NoError(t, err)
assert.Equal(t, 3, len(assets), "expected 3 Pods to be returned from matched Namspaces")
assert.Equal(t, 3, len(assets), "expected 3 Pods to be returned from matched Namespaces")

// Exclude w/glob '*default*'
assets, err = ListPods(p, pCfg, clusterIdentifier, NamespaceFilterOpts{exclude: []string{"*default*"}}, make(map[string][]K8sResourceIdentifier), ownershipDir)
require.NoError(t, err)
assert.Equal(t, 4, len(assets), "expected 4 Pods to be returned from non-excluded Namspaces")
assert.Equal(t, 4, len(assets), "expected 4 Pods to be returned from non-excluded Namespaces")
}
4 changes: 2 additions & 2 deletions _motor/platform/detector/platform_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ func (r *PlatformResolver) resolvePlatform(pf *platform.Platform, p os.Operating
for _, c := range r.Children {
detected, resolved := c.resolvePlatform(pf, p)
if resolved {
// add family hieracy
// add family hierarchy
detected.Family = append(pf.Family, r.Name)
return detected, resolved
}
}

// we reached this point, we know it is the platfrom but we could not
// we reached this point, we know it is the platform but we could not
// identify the system
// TODO: add generic platform instance
// TODO: should we return an error?
Expand Down
2 changes: 1 addition & 1 deletion apps/cnquery/cmd/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func (c *cnqueryPlugin) RunQuery(conf *run.RunQueryConfig, runtime *providers.Ru

// FIXME: workaround for gcp-snapshot
// For a gcp-snapshot asset, we start with a GCP connection.
// This get's overriden by a filesystem connection. The fileswystem connection is what we need for the scan
// This get's overridden by a filesystem connection. The filesystem connection is what we need for the scan
// But later, we need the GCP runtime to cleanup the snapshot disk
if runtime.Provider.Instance.Name == "gcp" && runtime.Provider.Connection.Name == "filesystem" {
defer runtime.Close()
Expand Down
2 changes: 1 addition & 1 deletion cli/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func initConfig() {
// override values with env variables
viper.SetEnvPrefix("mondoo")
// to parse env variables properly we need to replace some chars
// all hypens need to be underscores
// all hyphens need to be underscores
// all dots neeto to be underscores
replacer := strings.NewReplacer("-", "_", ".", "_")
viper.SetEnvKeyReplacer(replacer)
Expand Down
2 changes: 1 addition & 1 deletion cli/prof/prof.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (

// InitProfiler sets up the go profiler based on the MONDOO_PROF environment
// variable.
// MONDO_PROF is a list of comma seperated key/key=value.
// MONDO_PROF is a list of comma separated key/key=value.
// Allowed keys:
// - `enable`: Enables the profiler if no value is provided, or the value of
// `true` is provided
Expand Down
6 changes: 3 additions & 3 deletions cli/providers/providers.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func detectConnectorName(args []string, commands []*Command) (string, bool) {
err := preRunRoot.Execute()
if err != nil {
log.Debug().Err(err).Msg("early detection error")
log.Error().Msg("failed to run early comman detection")
log.Error().Msg("failed to run early command detection")
return "", false
}

Expand Down Expand Up @@ -166,12 +166,12 @@ func setConnector(provider *plugin.Provider, connector *plugin.Connector, run fu
{
Long: "record",
Type: plugin.FlagType_String,
Desc: "Record all resouce calls and use resouces in the recording",
Desc: "Record all resource calls and use resources in the recording",
},
{
Long: "use-recording",
Type: plugin.FlagType_String,
Desc: "Use a recording to inject resouces data (read-only)",
Desc: "Use a recording to inject resource data (read-only)",
},
{
Long: "pretty",
Expand Down
10 changes: 5 additions & 5 deletions cli/shell/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,15 +397,15 @@ func (s *Shell) renderResources(resources map[string]*resources.ResourceInfo, ke

rows := []rowEntry{}
maxk := 0
const seperator = ":"
const separator = ":"

for i := range keys {
k := keys[i]
resource := resources[k]

keyLength := len(resource.Name) + len(seperator)
keyLength := len(resource.Name) + len(separator)
rows = append(rows, rowEntry{
s.Theme.PolicyPrinter.Secondary(resource.Name) + seperator,
s.Theme.PolicyPrinter.Secondary(resource.Name) + separator,
keyLength,
resource.Title,
})
Expand Down Expand Up @@ -435,9 +435,9 @@ func (s *Shell) renderResources(resources map[string]*resources.ResourceInfo, ke
displayType = s.Theme.PolicyPrinter.Disabled(fieldType)
}

keyLength = len(fieldName) + len(fieldType) + len(seperator)
keyLength = len(fieldName) + len(fieldType) + len(separator)
rows = append(rows, rowEntry{
s.Theme.PolicyPrinter.Secondary(fieldName) + displayType + seperator,
s.Theme.PolicyPrinter.Secondary(fieldName) + displayType + separator,
keyLength,
fieldComment,
})
Expand Down
4 changes: 2 additions & 2 deletions explorer/mquery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func TestMqueryMerge(t *testing.T) {
Remediation: &Remediation{
Items: []*TypedDoc{{
Id: "default",
Desc: "a desciption",
Desc: "a description",
}},
},
},
Expand All @@ -33,7 +33,7 @@ func TestMqueryMerge(t *testing.T) {
Remediation: &Remediation{
Items: []*TypedDoc{{
Id: "default",
Desc: "b desciption",
Desc: "b description",
}},
},
},
Expand Down
2 changes: 1 addition & 1 deletion internal/datalakes/inmemory/inmemory.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func WithDb(runtime llx.Runtime, f func(*Db, *explorer.LocalServices) error) err
}

// Prefixes for all keys that are stored in the cache.
// Prevent collissions by creating namespaces for different types of data.
// Prevent collisions by creating namespaces for different types of data.
const (
dbIDQuery = "q\x00"
dbIDQueryPack = "qp\x00"
Expand Down
2 changes: 1 addition & 1 deletion llx/builtin_simple.go
Original file line number Diff line number Diff line change
Expand Up @@ -2233,7 +2233,7 @@ func stringSplitV2(e *blockExecutor, bind *RawData, chunk *Chunk, ref uint64) (*
return &RawData{
Type: types.Array(types.String),
Value: nil,
Error: errors.New("failed to split string, seperator was null"),
Error: errors.New("failed to split string, separator was null"),
}, 0, nil
}

Expand Down
2 changes: 1 addition & 1 deletion llx/rawdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type RawData struct {
Error error `json:"error,omitempty"`
}

// a helper structure exclusively used for json unmarshaling of errors
// a helper structure exclusively used for json unmarshalling of errors
// TODO: find a better way of doing this, this workaround is annoying
type errData struct {
Error string `json:"error"`
Expand Down
2 changes: 1 addition & 1 deletion mql/internal/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func (nodeData *ExecutionQueryNodeData) recalculate() *envelope {
nodeData.run()
}

// An empty evelope notifies the parent. These nodes always point at
// An empty envelope notifies the parent. These nodes always point at
// Datapoint nodes. The datapoint nodes don't need this message, and
// it actually makes more work for the datapoint node. The reason to
// send it is to uphold the contract of if something changes, we push
Expand Down
4 changes: 2 additions & 2 deletions mql/internal/nodes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ func TestExecutionQueryNode(t *testing.T) {
assert.Nil(t, data)
select {
case <-q:
assert.Fail(t, "not ready for exectuion")
assert.Fail(t, "not ready for execution")
default:
}
})
Expand Down Expand Up @@ -303,7 +303,7 @@ func TestExecutionQueryNode(t *testing.T) {

select {
case <-q:
assert.Fail(t, "not ready for exectuion")
assert.Fail(t, "not ready for execution")
default:
}
})
Expand Down
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/lr/cli/cmd/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ var docsCmd = &cobra.Command{

var docsYamlCmd = &cobra.Command{
Use: "yaml",
Short: "generates yaml docs skeleton file and merges it into existing defintion",
Short: "generates yaml docs skeleton file and merges it into existing definition",
Long: `parse an LR file and generates a yaml file structure for additional documentation.`,
Args: cobra.MinimumNArgs(1),
Run: func(cmd *cobra.Command, args []string) {
Expand Down
2 changes: 1 addition & 1 deletion providers-sdk/v1/lr/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func resourceInit(r *Resource, fields map[string]*resources.Field, ast *LR) (*re
for _, arg := range i.Args {
typ := arg.Type.Type(ast)
if typ == types.Unset {
return nil, errors.New("A field in the init that isnt found in the resource must have a type assigned. Field \"" + arg.ID + "\"")
return nil, errors.New("A field in the init that isn't found in the resource must have a type assigned. Field \"" + arg.ID + "\"")
}

ref, ok := fields[arg.ID]
Expand Down
2 changes: 1 addition & 1 deletion providers-sdk/v1/plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type ParseArgsFun func(runtime *Runtime, args map[string]*llx.RawData) (map[stri
// (Note: if necessary, parse arguments beforehand).
type CreateResource func(runtime *Runtime, args map[string]*llx.RawData) (Resource, error)

// ResourceFactory is generated for every resource and helps to initialze it
// ResourceFactory is generated for every resource and helps to initialize it
// and parse its arguments. This is focused on everything that is done
// within a plugin, not beyond (recording, upstream etc).
type ResourceFactory struct {
Expand Down
2 changes: 1 addition & 1 deletion providers-sdk/v1/plugin/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ func GetOrCompute[T any](cached *TValue[T], compute func() (T, error)) *TValue[T
}

// this only happens if the function set the field proactively, in which
// case we grab the value from the cached entry for consistancy
// case we grab the value from the cached entry for consistency
if cached.State&StateIsSet != 0 {
return cached
}
Expand Down
2 changes: 1 addition & 1 deletion providers-sdk/v1/util/convert/dict.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package convert
import "encoding/json"

// TODO: These functions are very heavyweight and prime candidates to
// be replaced by better laternatives.
// be replaced by better alternatives.

// JsonToDict converts a raw golang object (typically loaded from JSON)
// into a `dict` type
Expand Down
2 changes: 1 addition & 1 deletion providers-sdk/v1/util/jobpool/jobpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func NewJob(f func() (JobResult, error)) *Job {
// Run runs a job and does appropriate accounting via a given sync.WorkGroup
func (t *Job) Run(wg *sync.WaitGroup) {
if t.f == nil {
t.Err = fmt.Errorf("no funtion to run in jobpool: %s", t.Err)
t.Err = fmt.Errorf("no function to run in jobpool: %s", t.Err)
} else {
t.Result, t.Err = t.f()
}
Expand Down
2 changes: 1 addition & 1 deletion providers/aws/connection/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const (
DiscoveryECR = "ecr"
DiscoveryECS = "ecs"

DiscoveryAll = "all" // resources, accounts, instances, ecr, ecs, everrrything
DiscoveryAll = "all" // resources, accounts, instances, ecr, ecs, everything
DiscoveryAuto = "auto" // just the account for now

// API scan
Expand Down
2 changes: 1 addition & 1 deletion providers/aws/resources/aws_iam.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (a *mqlAwsIam) credentialReport() ([]interface{}, error) {
if gresp.State == iamtypes.ReportStateTypeStarted || gresp.State == iamtypes.ReportStateTypeInprogress {
// we need to wait
} else if gresp.State == iamtypes.ReportStateTypeComplete {
// we do not neet do do anything
// we do not need do do anything
} else {
// unsupported report state
return nil, fmt.Errorf("aws iam credential report state is not supported: %s", gresp.State)
Expand Down
12 changes: 6 additions & 6 deletions providers/azure/resources/cloud_defender.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ const (
arcClusterDefenderExtensionDefinitionId string = "/providers/Microsoft.Authorization/policyDefinitions/708b60a6-d253-4fe0-9114-4be4c00f012c"
kubernetesClusterDefenderExtensionDefinitionId string = "/providers/Microsoft.Authorization/policyDefinitions/64def556-fbad-4622-930e-72d1d5589bf5"

arcClusterPolicyExtensionDefinitionId string = "/providers/Microsoft.Authorization/policyDefinitions/0adc5395-9169-4b9b-8687-af838d69410a"
kubernetesClusterPolicyExtensonDefinitionId string = "/providers/Microsoft.Authorization/policyDefinitions/0adc5395-9169-4b9b-8687-af838d69410a"
arcClusterPolicyExtensionDefinitionId string = "/providers/Microsoft.Authorization/policyDefinitions/0adc5395-9169-4b9b-8687-af838d69410a"
kubernetesClusterPolicyExtensionDefinitionId string = "/providers/Microsoft.Authorization/policyDefinitions/0adc5395-9169-4b9b-8687-af838d69410a"
)

func (a *mqlAzureSubscriptionCloudDefenderService) id() (string, error) {
Expand Down Expand Up @@ -145,7 +145,7 @@ func (a *mqlAzureSubscriptionCloudDefenderService) defenderForContainers() (inte
kubernetesDefender := false
arcDefender := false
kubernetesPolicyExt := false
arcPoilcyExt := false
arcPolicyExt := false
for _, it := range pas.PolicyAssignments {
if it.Properties.PolicyDefinitionID == arcClusterDefenderExtensionDefinitionId &&
it.Properties.Scope == fmt.Sprintf("/subscriptions/%s", subId) {
Expand All @@ -157,17 +157,17 @@ func (a *mqlAzureSubscriptionCloudDefenderService) defenderForContainers() (inte
}
if it.Properties.PolicyDefinitionID == arcClusterPolicyExtensionDefinitionId &&
it.Properties.Scope == fmt.Sprintf("/subscriptions/%s", subId) {
arcPoilcyExt = true
arcPolicyExt = true
}
if it.Properties.PolicyDefinitionID == kubernetesClusterPolicyExtensonDefinitionId &&
if it.Properties.PolicyDefinitionID == kubernetesClusterPolicyExtensionDefinitionId &&
it.Properties.Scope == fmt.Sprintf("/subscriptions/%s", subId) {
kubernetesPolicyExt = true
}
}

def := defenderForContainers{
DefenderDaemonSet: arcDefender && kubernetesDefender,
AzurePolicyForKubernetes: arcPoilcyExt && kubernetesPolicyExt,
AzurePolicyForKubernetes: arcPolicyExt && kubernetesPolicyExt,
}
return convert.JsonToDict(def)
}
Expand Down
2 changes: 1 addition & 1 deletion providers/azure/resources/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ func (a *mqlAzureSubscriptionMonitorServiceActivityLog) alerts() ([]interface{},
return res, nil
}

// TODO: we should check how the plugin generic struct works when the value isnt set, can we rely on default value
// TODO: we should check how the plugin generic struct works when the value isn't set, can we rely on default value
// or need to use something else? goes for both storageAccount implementations
func (a *mqlAzureSubscriptionMonitorServiceLogprofile) storageAccount() (*mqlAzureSubscriptionStorageServiceAccount, error) {
storageAccId := a.StorageAccountId.Data
Expand Down
2 changes: 1 addition & 1 deletion providers/coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (c *coordinator) Start(id string, update UpdateProvidersConfig) (*RunningPr
if update.Enabled {
// We do not stop on failed updates. Up until some other errors happens,
// things are still functional. We want to consider failure, possibly
// with a config entry in the futuer.
// with a config entry in the future.
updated, err := c.tryProviderUpdate(provider, update)
if err != nil {
log.Error().
Expand Down
2 changes: 1 addition & 1 deletion providers/core/resources/versions/deb/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func TestParse(t *testing.T) {
// Test epoched
{"1:0", version{epoch: 1, version: "0", revision: ""}, false},
{"5:1", version{epoch: 5, version: "1", revision: ""}, false},
// Test multiple hypens
// Test multiple hyphens
{"0:0-0-0", version{epoch: 0, version: "0-0", revision: "0"}, false},
{"0:0-0-0-0", version{epoch: 0, version: "0-0-0", revision: "0"}, false},
// Test multiple colons
Expand Down
2 changes: 1 addition & 1 deletion providers/core/resources/versions/rpm/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func TestParse(t *testing.T) {
// Test epoched
{"1:0", version{epoch: 1, version: "0", release: ""}, false},
{"5:1", version{epoch: 5, version: "1", release: ""}, false},
// Test multiple hypens
// Test multiple hyphens
{"0:0-0-0", version{epoch: 0, version: "0", release: "0-0"}, false},
{"0:0-0-0-0", version{epoch: 0, version: "0", release: "0-0-0"}, false},
// Test multiple colons
Expand Down
2 changes: 1 addition & 1 deletion providers/gcp/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func (s *Service) ParseCLI(req *plugin.ParseCLIReq) (*plugin.ParseCLIRes, error)
}
// ^^ snapshot and instance flags

// these flags are currently only used for the instnace sub-command
// these flags are currently only used for the instance sub-command
var createSnapshot string
if x, ok := flags["create-snapshot"]; ok && len(x.Value) != 0 {
createSnapshot = string(x.Value)
Expand Down
Loading

0 comments on commit a08097d

Please sign in to comment.