Code Monkey home page Code Monkey logo

Comments (3)

lucasvmiguel avatar lucasvmiguel commented on May 24, 2024

I'll raise a PR soon to fix that

from go-jsonschema.

omissis avatar omissis commented on May 24, 2024

hi @lucasvmiguel, the PR has been merged and your change has been released as part of the release v0.14.1, so I'm closing this issue.

Thank you for contributing to go-jsonschema! 🚀

from go-jsonschema.

andrewpollock avatar andrewpollock commented on May 24, 2024

Weird, I'm running whatever go install github.com/atombender/go-jsonschema@latest gave me 3 days ago, and I think I'm still being bitten by this bug...

$ go list -m all | grep json
github.com/atombender/go-jsonschema v0.14.1

What was generated from go-jsonschema -p cves --resolve-extension json /tmp/cve_api_json_2.0.schema from here:

// UnmarshalJSON implements json.Unmarshaler.
func (j *LangString) UnmarshalJSON(b []byte) error {
        var raw map[string]interface{}
        if err := json.Unmarshal(b, &raw); err != nil {
                return err
        }
        if v, ok := raw["lang"]; !ok || v == nil {
                return fmt.Errorf("field lang in LangString: required")
        }
        if v, ok := raw["value"]; !ok || v == nil {
                return fmt.Errorf("field value in LangString: required")
        }
        type Plain LangString
        var plain Plain
        if err := json.Unmarshal(b, &plain); err != nil {
                return err
        }
        if len(plain.Value) > 4096 {
                return fmt.Errorf("field %s length: must be <= %d", "value", 4096)
        }
        *j = LangString(plain)
        return nil
}
Failed to decode "../test_data/nvdcve-2.0-2020.json": field value length: must be <= 4096

The record in question is https://services.nvd.nist.gov/rest/json/cves/2.0?cveId=CVE-2020-35800 (the Spanish description field), which by my calculations, has a length of exactly 4,096.

I added a bit of additional instrumentation, and ended up with:

Failed to decode "../test_data/nvdcve-2.0-2020.json": field value length: must be <= 4096, have 4098

So something is afoot here with the decoding I think, not this logic, although, I added even more instrumentation (VS Code was unhelpfully truncating my view of these mysterious extra characters and:

Failed to decode "../test_data/nvdcve-2.0-2020.json": field value length: must be <= 4096, have 4098 with content "Determinados dispositivos NETGEAR están afectados por una configuración incorrecta de los ajustes de seguridad.&#xa0;Esto afecta a AC2100 versiones &lt; 1.2.0.72, AC2400 versiones &lt; 1.2.0.72, AC2600 versiones &lt; 1.2.0.72, CBK40 versiones &lt; 2.5.0.10, CBR40 versiones &lt; 2.5.0.10, D6000 versiones &lt; 1.0.0.80, D6220 versiones &lt; 1.0.0.60, D6400 versiones &lt; 1.0.0.94, D7000v2 versiones &lt; 1.0.0.62, D7800 versiones &lt; 1.0.3.48, D8500 versiones &lt; 1.0.3.50, DC112A versiones &lt; 1.0.0.48, DGN2200v4 versiones &lt; 1.0.0.114, DM200 versiones &lt; 1.0.0.66, EAX20 versiones &lt; 1.0.0.36, EAX80 versiones &lt; 1.0.1.62, EX2700 versiones &lt; 1.0.1.58, EX3110 versiones &lt; 1.0.1.68, EX3700 versiones &lt; 1.0.0.84, EX3800 versiones &lt; 1.0.0.84, EX3920 versiones &lt; 1.0.0.84, EX6000 versiones &lt; 1.0.0.44, EX6100v2 versiones &lt; 1.0.1.94, EX6110 versiones &lt; 1.0.1.68, EX6120 versiones &lt; 1.0. 0.54, EX6130 versiones &lt; 1.0.0.36, EX6150v1 versiones &lt; 1.0.0.46, EX6150v2 versiones &lt; 1.0.1.94, EX6200v1 versiones &lt; 1.0.3.94, EX6250 versiones &lt; 1.0.0.128, EX6400 versiones &lt; 1.0.2.152, EX6400v2 versiones &lt; 1.0.0.128, EX6410 versiones &lt; 1.0.0.128, EX6920 versiones &lt; 1.0.0.54, EX7000 versiones &lt; 1.0.1.90, EX7300 versiones &lt; 1.0.2.152, EX7300v2 versiones &lt; 1.0.0.128, EX7320 versiones &lt; 1.0.0.128, EX7500 versiones &lt; 1.0.0.68, EX7700 versiones &lt; 1.0.0.210, EX8000 antes e 1.0.1.224, MK62 versiones &lt; 1.0.5.102, MR60 versiones &lt; 1.0.5.102, MS60 versiones &lt; 1.0.5.102, R6120 versiones &lt; 1.0.0.70, R6220 versiones &lt; 1.1.0.100, R6230 versiones &lt; 1.1.0.100, R6250 versiones &lt; 1.0.4.42, R6260 versiones &lt; 1.1 .0.76, R6300v2 versiones &lt; 1.0.4.42, R6330 versiones &lt; 1.1.0.76, R6350 versiones &lt; 1.1.0.76, R6400v1 versiones &lt; 1.0.1.62, R6400v2 versiones &lt; 1.0.4.98, R6700v1 versiones &lt; 1.0.2.16, R6700v2 versiones &lt; 1.2.0.72, R6700v3 versiones &lt; 1.0.4.98, R6800 versiones &lt; 1.2.0.72, R6800 antes 1.2.0.72, R6850 versiones &lt; 1.1.0.76, R6900 versiones &lt; 1.0.2.16, R6900P versiones &lt; 1.3.2.124, R6900v2 versiones &lt; 1.2.0.72, R7000 versiones &lt; 1.0.11.106, R7000P versiones &lt; 1.3.2.124, R7100LG versiones &lt; 1.0.0.56, R7200 versiones &lt; 1.2. 0.72, R7350 versiones &lt; 1.2.0.72, R7400 versiones &lt; 1.2.0.72, R7450 versiones &lt; 1.2.0.72, R7500v2 versiones &lt; 1.0.3.48, R7800 versiones &lt; 1.0.2.74, R7850 versiones &lt; 1.0.5.60, R7900 versiones &lt; 1.0.4.26, R7900P versiones &lt; 1.4.1.62, R7960P versiones &lt; 1.4.1.62, R8000 versiones &lt; 1.0.4.58, R8000P versiones &lt; 1.4.1.62, R8300 versiones &lt; 1.0.2.134, R8500 versiones &lt; 1.0.2.134, R8900 versiones &lt; 1.0.5.24, R9000 versiones &lt; 1.0.5.24, RAX120 versiones &lt; 1.0.1.136, RAX15 versiones &lt; 1.0.1.64, RAX20 versiones &lt; 1.0.1.64, RAX200 versiones &lt; 1.0.5.24, RAX35 versiones &lt; 1.0.3.80, RAX40 versiones &lt; 1.0.3.80, RAX45 versiones &lt; 1.0.2.64, RAX50 versiones &lt; 1.0.2.64, RAX75 versiones &lt; 1.0.3.102, RAX80 versiones &lt; 1.0. 3.102, RB K12 versiones &lt; 2.6.1.44, RBR10 versiones &lt; 2.6.1.44, RBS10 versiones &lt; 2.6.1.44, RBK20 versiones &lt; 2.6.1.38, RBR20 versiones &lt; 2.6.1.36, RBS20 versiones &lt; 2.6.1.38, RBK40 versiones &lt; 2.6.1.38, RBR40 versiones &lt; 2.6.1.38, RBS40 antes 2.6.1.38, RBK50 versiones &lt; 2.6.1.40, RBR50 versiones &lt; 2.6.1.40, RBS50 versiones &lt; 2.6.1.40, RBK752 versiones &lt; 3.2.16.6, RBR750 versiones &lt; 3.2.16.6, RBS750 versiones &lt; 3.2.16.6, RBK842 versiones &lt; 3.2.16.6, RBR840 versiones &lt; 3.2. 16.6, RBS840 versiones &lt; 3.2.16.6, RBK852 versiones &lt; 3.2.16.6, RBR850 versiones &lt; 3.2.16.6, RBS850 versiones &lt; 3.2.16.6, RBS40V versiones &lt; 2.5.1.6, RBS40V-200 versiones &lt; 1.0.0.46, RBS50Y versiones &lt; 2.6.1.40, RBW30 versiones &lt; 2.5. 0.4, RS400 versiones &lt; 1.5.0.48, WN2500RPv2 versiones &lt; 1.0.1.56, WN3000RPv3 versiones &lt; 1.0.2.86, WN3500RPv1 versiones &lt; 1.0.0.28, WNDR3400v3 versiones &lt; 1.0.1.32, WNR1000v3 versiones &lt; 1.0.2.78, WNR2000v2 versiones &lt; 1.2.0.12, XR30"

Again, by my calculations, the content of plain.Value seems to have a length of exactly 4,096.

I am officially very confused. If the length was way out, I'd say something unexpected was going on with respect to Unicode, oh wait, there's this &#xa0; in there, which is a Unicode non-breaking space?

from go-jsonschema.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.