Uploaded image for project: 'National Data Service'
  1. National Data Service
  2. NDS-387

"New XXX" forms in Add/Edit Spec view should validate user input

XMLWordPrintableJSON

    • NDS Sprint 9

      Currently, the Add/Edit Spec view consists of one large <form> element spread out over multiple tabs. This makes using ngMessages to validate the page quite simple, as checking the validity of the entire form can be condensed to a single method call to formName.$invalid.

      We also allow the user to add their own port/volume/variable mappings, which requires its own validation. ngMessages can handle nested forms, but the default implementation assumes that if a sub-form is invalid that the whole form is invalid, which does not suit our needs.

      Each sub-form's validation requirements are detailed below:

      New Dependency

      This form should, at the very least:

      • prevent the user from adding a service as a dependency of itself (endless recursion?)
      • may need to explore further edge cases here
      New Environment Variable Validation Requirements

      After doing some research, there appears to be a very high limit on the maximum allowed length for an environment variable's value. I have not, however, been able to find much on the maximum length of the variable names.

      I propose that we enforce an arbitrary limit of 80 characters for the name and a very high arbitrary limit for the value (say... 4096?)

      New Volume Validation Requirements

      We have discussed automatically generating these names and hiding them altogether from the user. If we do choose to allow the user to input this field, Kubernetes requires that all identifiers for volumes or volumeMounts be true DNS labels.

      This means that any volume name must:

      • start with lowercase alphanumeric characters and consist only of lowercase alphanumeric characters and dash ("-")
      • be no longer than 63 total characters

      In any case, we also need to validate the path.

      Volume path must:

      • be an absolute path
        • i.e. must start with /
        • should we prevent mounting critical system directories?
      • may not contain spaces
        • should we allow spaces iff surrounding quotes / escaped?
      • should we prevent special characters?
        • supposedly "([^\0 !$`&*()+]|\\\(\ |!|\$|\`|\&|*|(|)|+))+" is a valid regex for UNIX file paths - need to test it further
      New Port Validation Requirements

      Port number must be between 1 and 65535

      Protocol must be one of:

      • http
      • tcp (currently unsupported - see NDS-395)
      • udp (currently unsupported)

      Access must be one of:

      • none
      • internal (service is assigned a static IP)
      • external (service is assigned a static IP, along with a NodePort and / or Ingress rule)

      This story is complete when the above validation is performed on the "New XXX" forms without affecting the validation present on the parent form.

              lambert8 Sara Lambert
              lambert8 Sara Lambert
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved:

                  Estimated:
                  Original Estimate - 1 day
                  1d
                  Remaining:
                  Time Spent - 5 hours Remaining Estimate - 3 hours
                  3h
                  Logged:
                  Time Spent - 5 hours Remaining Estimate - 3 hours
                  5h