今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Challenge: Secure input
(upbeat music) - [Instructor] Here we have a code that processes activities. It has a User, a StartTime, an EndTime and a Description, and we have the function to process an activity that gets it from an io.Reader. We use a json.decoder to decode the activity, log it out, and then potentially do some other work. You should secure this function by limit the data read to at most 10 kilobytes and validate the activity record. For example, the StartTime should be before the EndTime. There are two records here, the activity-1.json, which is a valid record, and the activity-2, which is not a valid record. You can test it by running the code, for example, go run. and then <activity-1.json, and when you run it with activity -2, it should fail. This one does not.