Skip to content

Commit

Permalink
Merge branch 'master' into subscriber-fuzz
Browse files Browse the repository at this point in the history
  • Loading branch information
amityt authored Mar 12, 2024
2 parents 9147a86 + 547a367 commit 1a55a0e
Show file tree
Hide file tree
Showing 1,153 changed files with 2,727 additions and 199,196 deletions.
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,19 @@ Feel free to reach out if you have any queries,concerns, or feature requests

- To join our [Slack Community](https://slack.litmuschaos.io/) and meet our community members, put forward your questions & opinions, join the #litmus channel on the [Kubernetes Slack](https://slack.k8s.io/).
### Community Meetings
The Litmus community meets on the third wednesday of every month at 10:00PM IST/6:30 PM CEST/9:30 AM PST.

1. Community Meetings
These will be hosted every 3rd Wednesday of every month at 5:30 PM GMT /6:30 PM CEST /10 PM IST
The community meetings will involve discussing community updates, sharing updates on new features/releases and discussing user/adopter stories. Everyone in the community is invited for the same to participate in the LitmusChaos community meetings.


2. Contributor Meetings
These will be hosted every second & last Thursday of every month at 2:30 PM GMT /3:30 PM CEST /7 PM IST
The contributor meetings are only meant to discuss technical and non-technical contributions to LitmusChaos. Maintainers, present Contributors and aspiring contributors are invited to participate in the LitmusChaos contributor meetings to discuss issues, fixes, enhancements and future contributions


Fill out the [LitmusChaos Meetings invite form](https://forms.gle/xYZyZ2gTWMqz7xSs7) to get your Calendar invite!


- [Sync Up Meeting Link](https://harness-io.zoom.us/j/95100368978?pwd=b2VrdCtaakE5U3dhOElFMUJOaXVOUT09)
- [Sync Up Agenda & Meeting Notes](https://hackmd.io/a4Zu_sH4TZGeih-xCimi3Q)
Expand Down
36 changes: 36 additions & 0 deletions chaoscenter/authentication/pkg/utils/utils_fuzz_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package utils

import (
"fmt"
"testing"
)

func FuzzSanitizeString(f *testing.F) {
f.Fuzz(func(t *testing.T, input string) {
err := ValidateStrictPassword(input)
if err != nil {
if isExpectedError(err) {
fmt.Printf("Expected validation failure for input '%s': %v\n", input, err)
} else {
fmt.Printf("Unexpected validation failure for input '%s': %v\n", input, err)
}
}
})
}

func isExpectedError(err error) bool {
expectedErrors := []string{
"password is less than 8 characters",
"password does not contain digits",
"password does not contain lowercase alphabets",
"password does not contain uppercase alphabets",
"password does not contain special characters",
}

for _, expected := range expectedErrors {
if err.Error() == expected {
return true
}
}
return false
}
2 changes: 1 addition & 1 deletion chaoscenter/fuzz_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ cd chaoscenter/graphql/server && go mod download
go install github.com/AdamKorcz/go-118-fuzz-build@latest
go get github.com/AdamKorcz/go-118-fuzz-build/testing

compile_native_go_fuzzer $(pwd)/pkg/environment/handler FuzzTestGetEnvironment test-fuzz
compile_native_go_fuzzer $(pwd)/pkg/environment/handler/fuzz_tests FuzzTestGetEnvironment test-fuzz
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ enum ExperimentRunStatus {
Skipped
Error
Timeout
Terminated
Queued
NA
}

Expand Down Expand Up @@ -756,7 +758,7 @@ extend type Mutation {
Updates the experiment
"""
updateChaosExperiment(
request: ChaosExperimentRequest
request: ChaosExperimentRequest!
projectID: ID!
): ChaosExperimentResponse!

Expand Down
1 change: 1 addition & 0 deletions chaoscenter/graphql/server/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.20

require (
github.com/99designs/gqlgen v0.17.42
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24
github.com/argoproj/argo-workflows/v3 v3.3.1
github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32
github.com/gin-contrib/cors v1.3.1
Expand Down
2 changes: 2 additions & 0 deletions chaoscenter/graphql/server/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
github.com/99designs/gqlgen v0.17.42 h1:BVWDOb2VVHQC5k3m6oa0XhDnxltLLrU4so7x/u39Zu4=
github.com/99designs/gqlgen v0.17.42/go.mod h1:GQ6SyMhwFbgHR0a8r2Wn8fYgEwPxxmndLFPhU63+cJE=
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 h1:bvDV9vkmnHYOMsOr4WLk+Vo07yKIzd94sVoIqshQ4bU=
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24/go.mod h1:8o94RPi1/7XTJvwPpRSzSUedZrtlirdB3r9Z20bi2f8=
github.com/Azure/azure-sdk-for-go v32.5.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc=
github.com/Azure/azure-sdk-for-go v35.0.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc=
github.com/Azure/azure-sdk-for-go v43.0.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc=
Expand Down

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

24 changes: 9 additions & 15 deletions chaoscenter/graphql/server/graph/generated/generated.go

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

6 changes: 5 additions & 1 deletion chaoscenter/graphql/server/graph/model/models_gen.go

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

48 changes: 44 additions & 4 deletions chaoscenter/graphql/server/pkg/chaos_experiment/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ func (c *ChaosExperimentHandler) SaveChaosExperiment(ctx context.Context, reques
if err != nil {
return "", err
}

// Updating the existing experiment
if wfDetails.ExperimentID == request.ID {
logrus.WithFields(logFields).Info("request received to update k8s chaos experiment")
Expand All @@ -121,14 +122,20 @@ func (c *ChaosExperimentHandler) SaveChaosExperiment(ctx context.Context, reques
}
}

// Gitops Update
err = c.gitOpsService.UpsertExperimentToGit(ctx, projectID, newRequest)
if err != nil {
logrus.WithFields(logFields).Errorf("failed to push the experiment manifest to Git., err: %v", err)
return "", err
}

err = c.chaosExperimentService.ProcessExperimentUpdate(newRequest, username, wfType, revID, false, projectID, nil)
if err != nil {
return "", err
}

return "experiment updated successfully", nil
}

err = c.validateDuplicateExperimentName(ctx, projectID, request.Name)
if err != nil {
return "", err
Expand All @@ -137,6 +144,13 @@ func (c *ChaosExperimentHandler) SaveChaosExperiment(ctx context.Context, reques
// Saving chaos experiment in the DB
logrus.WithFields(logFields).Info("request received to save k8s chaos experiment")

// Gitops Update
err = c.gitOpsService.UpsertExperimentToGit(ctx, projectID, newRequest)
if err != nil {
logrus.WithFields(logFields).Errorf("failed to push the experiment manifest to Git, err: %v", err)
return "", err
}

err = c.chaosExperimentService.ProcessExperimentCreation(ctx, newRequest, username, projectID, wfType, revID, nil)
if err != nil {
return "", err
Expand All @@ -160,6 +174,12 @@ func (c *ChaosExperimentHandler) CreateChaosExperiment(ctx context.Context, requ
return nil, err
}

// Gitops Update
err = c.gitOpsService.UpsertExperimentToGit(ctx, projectID, newRequest)
if err != nil {
return nil, err
}

tkn := ctx.Value(authorization.AuthKey).(string)
uid, err := authorization.GetUsername(tkn)
err = c.chaosExperimentService.ProcessExperimentCreation(context.TODO(), newRequest, uid, projectID, wfType, revID, r)
Expand All @@ -177,7 +197,6 @@ func (c *ChaosExperimentHandler) CreateChaosExperiment(ctx context.Context, requ
}

func (c *ChaosExperimentHandler) DeleteChaosExperiment(ctx context.Context, projectID string, workflowID string, workflowRunID *string, r *store.StateData) (bool, error) {

query := bson.D{
{"experiment_id", workflowID},
{"project_id", projectID},
Expand Down Expand Up @@ -223,6 +242,17 @@ func (c *ChaosExperimentHandler) DeleteChaosExperiment(ctx context.Context, proj

workflowRun.IsRemoved = true

wf := model.ChaosExperimentRequest{
ExperimentID: &workflow.ExperimentID,
ExperimentName: workflow.Name,
}

err = c.gitOpsService.DeleteExperimentFromGit(ctx, projectID, &wf)
if err != nil {
logrus.Errorf("Failed to delete experiment manifest from git, err: %v", err)
return false, err
}

err = c.chaosExperimentRunService.ProcessExperimentRunDelete(ctx, query, workflowRunID, workflowRun, workflow, uid, r)
if err != nil {
return false, err
Expand All @@ -232,7 +262,7 @@ func (c *ChaosExperimentHandler) DeleteChaosExperiment(ctx context.Context, proj
return true, nil
}

func (c *ChaosExperimentHandler) UpdateChaosExperiment(ctx context.Context, request *model.ChaosExperimentRequest, projectID string, r *store.StateData) (*model.ChaosExperimentResponse, error) {
func (c *ChaosExperimentHandler) UpdateChaosExperiment(ctx context.Context, request model.ChaosExperimentRequest, projectID string, r *store.StateData) (*model.ChaosExperimentResponse, error) {
var (
revID = uuid.New().String()
)
Expand All @@ -243,12 +273,19 @@ func (c *ChaosExperimentHandler) UpdateChaosExperiment(ctx context.Context, requ
return nil, err
}

newRequest, wfType, err := c.chaosExperimentService.ProcessExperiment(ctx, request, projectID, revID)
newRequest, wfType, err := c.chaosExperimentService.ProcessExperiment(ctx, &request, projectID, revID)
if err != nil {
return nil, err
}
tkn := ctx.Value(authorization.AuthKey).(string)
uid, err := authorization.GetUsername(tkn)

err = c.gitOpsService.UpsertExperimentToGit(ctx, projectID, newRequest)
if err != nil {
logrus.Errorf("failed to push experiment manifest to git, err: %v", err)
return nil, err
}

err = c.chaosExperimentService.ProcessExperimentUpdate(newRequest, uid, wfType, revID, false, projectID, r)
if err != nil {
return nil, err
Expand Down Expand Up @@ -971,6 +1008,9 @@ func (c *ChaosExperimentHandler) getWfRunDetails(workflowIDs []string) (map[stri
}

func (c *ChaosExperimentHandler) DisableCronExperiment(username string, experiment dbChaosExperiment.ChaosExperimentRequest, projectID string, r *store.StateData) error {
if len(experiment.Revision) < 1 {
return fmt.Errorf("revision array is empty")
}
workflowManifest, err := sjson.Set(experiment.Revision[len(experiment.Revision)-1].ExperimentManifest, "spec.suspend", true)
if err != nil {
return err
Expand Down
Loading

0 comments on commit 1a55a0e

Please sign in to comment.