Documentation ¶
Overview ¶
Package integrity constitutes the 'Validation and Integrity library'. It is called by the allDB package.
This package's responsibility is to run code which verifies that every change to the database will result in a valid state. A state is valid if it can be rolled back to the previous state or moved forward into a new state AND Polyapp's code is capable of transporting and operating on it safely. The 'state' of a database object is its current contents. The ability to move between states can only take the form of read, create, update, delete, and deprecate operations. Polyapp's code is capable of transporting and operating on the objects safely if the object will not break any of the underlying databases and will not break any of the languages used in the layers below this one. An example of 'breaking the database' would be SQL injection or rejected set operations.
This package is very important because you may successfully write code which sets a document in the Firestore database but that same code would not work in the IDB database or in Elasticsearch or in the file system. If the database is saved to conditionally you might not realize your mistake until the code has already been deployed.
This package is also very important for security.
Index ¶
- func BackPopulate(data *common.Data) error
- func Convert(data *common.Data) error
- func ValidFirestoreFieldName(key string) string
- func ValidateAllDBs(queryable common.Queryable) error
- func ValidateElasticsearch(simplified map[string]interface{}) error
- func ValidateElasticsearchKey(k string) error
- func ValidateFile(simplified map[string]interface{}) error
- func ValidateFirestore(simplified map[string]interface{}) error
- func ValidateIndexedDB(simplified map[string]interface{}) error
- func ValidateLanguages(queryable common.Queryable) error
- func ValidatePolyapp(m map[string]interface{}) error
- func ValidatePolyappKey(k string) error
- func ValidatePostgres(simplified map[string]interface{}) error
- func ValidateSerialization(simplified map[string]interface{}) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BackPopulate ¶
BackPopulate pulls the Schema of this Data and if there are any blank fields in Data it populates them with zero values. This is very useful to ensure the Data in the database is fully populated, which is required by some functions like TaskGoalEvaluate.
func Convert ¶
Convert from common.Data in the format of "SchemaID" to the format of the schema's master Schema.
func ValidFirestoreFieldName ¶
ValidFirestoreFieldName returns "" if a key will be valid; a string which can be shown to the user otherwise
func ValidateAllDBs ¶
ValidateAllDBs validates many objects will not break the underlying databases this data will be stored in to.
func ValidateElasticsearch ¶
ValidateElasticsearch ensures the information being stored in Elasticsearch will not break the storage medium.
Source: https://www.elastic.co/guide/en/elasticsearch/reference/current/general-recommendations.html Documents must not be > 100MB or 25_000_000 unicode characters, however they should be much smaller than that usually.
elasticsearch limit is 512 bytes for document IDs https://discuss.elastic.co/t/maximum-length-of-a-specified-document-id/4262/3 4 bytes per string character; 512 / 4 = 128. We will reserve len("polyapp")*4 = 28 bytes in every key. Therefore our maximum ID size is ~99. But right now IDs are randomly generated so that should not be a problem.
func ValidateElasticsearchKey ¶
ValidateElasticsearchKey returns an error if the key provided is invalid or unsafe.
func ValidateFile ¶
ValidateFile ensures the information being stored in files will not break the storage medium.
func ValidateFirestore ¶
ValidateFirestore ensures the information being stored in Firestore will not break the database.
func ValidateIndexedDB ¶
ValidateIndexedDBData ensures simplified data will not break the IndexedDB database.
func ValidateLanguages ¶
ValidateLanguages ensures the change to the schema will not break any of the underlying languages where a 'language' is Go or SQL.
func ValidatePolyapp ¶
ValidatePolyapp ensures Polyapp's storage format is not being compromised by the data being stored.
func ValidatePolyappKey ¶
ValidatePolyappKey ensures a key k with a prefix "_ind_dom_sch_key" or "ind_dom_sch_key" or without a prefix like "key" does not contain restricted characters which would break Polyapp's client-side or server-side code.
This should be 2 different functions - one which is for prefixed keys and one which is not. But it isn't.
func ValidatePostgres ¶
ValidatePostgres ensures that field names can be encoded as column names by our code and that those column names will be valid.
func ValidateSerialization ¶
ValidateSerialization ensures all of the serialization schemes Polyapp uses can tolerate the input data structure That means JSON and Google's Protobuf. More information: https://owasp.org/www-project-top-ten/OWASP_Top_Ten_2017/Top_10-2017_A8-Insecure_Deserialization This function is substantially similar to the ValidateFile function.
Types ¶
This section is empty.