送信されたデータを指定された構造体にマーシャリングする直前に入力をサニタイズしようとしています。golangの入力データのサニタイズ方法は?
ここに私が使用しているモデルがあります。ここで
type Post struct {
Id int `json:"Id"`
CreatedAt time.Time `json:"CreatedAt"`
UpdatedAt time.Time `json:"UpdatedAt"`
CreatorId int `json:"CreatorId"`
Creator *User
Editors []int `json:"Editors"`
Status Status `json:"Status"`
Title string `json:"Title"`
ShortDescription string `json:"ShortDescription"`
Description string `json:"Description"`
Content string `json:"Content"`
Url string `json:"Url"`
Media *Media
Categories []Category `json:"Categories"`
Tags []Tag `json:"Tags"`
MediaId int `json:"MediaId"`
Keywords string `json:"Keywords"`
Data []string `json:"Data"`
}
どのように私は最も効果的にこのようにいずれかを削除し、このプロセスの間にReadJSON
要求時に、データ挿入前に上記のJSON形式のデータをサニタイズう
{"Id":1,"CreatedAt":"2016-10-11T21:29:46.134+02:00","UpdatedAt":"0001-01-01T00:00:00Z","CreatorId":1,"Editors":null,"Status":1,"Title":"This is the title of the first post, to be changed.<script>alert()</script>","ShortDescription":"this is the short description of this post","Description":"","Content":"Contrary to popular belief Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC making it over 2000 years old. Richard McClintock","Url":"lorem-ipsum-first"}
JSONデータを提出した可能性の一例です<script>alert()</script>.
で見られるような悪質なコード? 使用可能な追加情報がある場合は質問してください。追加することができれば幸いです。 ありがとう
あなたはおそらくこれを読んでください.florinpatan.ro/2016/10/why-you-should-not-use-iris-for-your-go.html)。私はあなたが切り替える必要があると言っているわけではありませんが、あなたは少なくとも、コミュニティの多くがアイリスについて持っている懸念を知っておくべきです。 – joshlf
実際にGoでフレームワークを使用する理由はありません。それは私が最も気に入っているものです。 –
少なくとも、私は今より後ではなく知っていました。 –