Alternative map sorting
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 25/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Necesita aclaración
- Estado de actividad
- Estancado
- Stack tecnológico
- c
- Área
- embedded-iot
Línea de trabajo
Comienza en cborvalidation.c alrededor de la línea 475 y revisa los flags existentes de ordenación de mapas y unicidad. Aclara si la ordenación alternativa debe reemplazar o complementar el comportamiento actual y, después, define el orden esperado, el tratamiento de las claves y el comportamiento ante claves duplicadas; la finalización depende de acordar el diseño y el alcance de la implementación.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Hello,
I've been looking into the CBOR validator and how maps are considered as sorted or not. In another project, I have previously been using another serialization standard that strictly defines maps in another way. Such as keys must only be strings, keys must be stored in lexicographical order and that no duplicates are allowed. Now we are looking into changing to cbor.
The CBOR specification does not strictly specifies what an ordered map is, but recommends that they should also be sorted in length. Meaning that "aa" > "b".
The alternatives are:
- Change sorting specification in our protocol (to order the fields like CBOR specification recommends)
- Not having sorted maps
- Finding/adapting a cbor library to allow for alternative sorting
Sorting is nice since is allows for linear parsing. Since we rely on this, we cannot directly swap to cbor. I would like to start a discussion of supporting an alternative sorting in tinycbor.
Wrote a short proof of concept for this (removes old sorting behavior) cborvalidation.c:475:
if (flags & CborValidateMapIsSorted) {
if (previous) {
uint64_t len1, len2;
const uint8_t *ptr;
/* extract the two lengths */
ptr = previous;
_cbor_value_extract_number(&ptr, it->parser->end, &len1);
ptr = current;
_cbor_value_extract_number(&ptr, it->parser->end, &len2);
size_t bytelen1 = (size_t)(previous_end - previous);
size_t bytelen2 = (size_t)(it->ptr - current);
/*
* Offset of actual key value (not including type information) is bytelenX - lenX??
* What if key value is indefinite??
*/
int r = memcmp(&previous[bytelen1 - len1], ¤t[bytelen2 - len2], len1 <= len2 ? len1 : len2);
if (r == 0 && len1 != len2)
r = len1 < len2 ? -1 : +1;
if (r > 0)
return CborErrorMapNotSorted;
if (r == 0 && (flags & CborValidateMapKeysAreUnique) == CborValidateMapKeysAreUnique)
return CborErrorMapKeysNotUnique;
}
Would it be possible to add a flag that would allow for this kind of sorting?
- Lenguaje dominante
- C
- Estrellas
- 634
- Forks
- 222
- Merge medio
- 1 d 25 min
- PR fusionados (30 d)
- 2
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de intel/tinycbor
-
CborValidateTagUse rejects valid tag 1 (epoch) with a floating-point value, and restricts tags 21-23 too muchPosiblemente ocupada @thiagomacieira la tomó hace 7 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
-
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
-
CBOR validation not worksAbierto
Dificultad 3/5 1-2 días Aptitud para principiantes 35/100
-
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
-
Dificultad 4/5 3-5 días Aptitud para principiantes 38/100
Todos los issues de intel/tinycbor
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Los mantenedores suelen responder en 1 día
-
severity: low
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
luainkernel/lunatik#1853 ·
Los mantenedores suelen responder en 1 día
-
encoding.binary: bounds check guard is compiled away, so decode functions read past the sliceAbierto
Dificultad 2/5 Medio día Aptitud para principiantes 70/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
resetes12/pokeemerald#204 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Los mantenedores suelen responder en 6 días