@cryptotaxi247 / kubo / commits / 6c22bf8ef

don't expose "version deps" on the gateway

TMI License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>

Steven Allen committed Apr 4, 2019 at 14:07 UTC 6c22bf8ef416fb8be6081d88cd15212f429428a2
1 file changed +12 -6
core/commands/root.go
+12 -6
@@ -160,6 +160,9 @@ var CommandsDaemonROCmd = CommandsCmd(RootRO)
160 // RefsROCmd is `ipfs refs` command
161 var RefsROCmd = &cmds.Command{}
162
163 +// VersionROCmd is `ipfs version` command (without deps).
164 +var VersionROCmd = &cmds.Command{}
165 +
166 var rootROSubcommands = map[string]*cmds.Command{
167 "commands": CommandsDaemonROCmd,
168 "cat": CatCmd,
@@ -192,24 +195,27 @@ var rootROSubcommands = map[string]*cmds.Command{
195 },
196 },
197 "resolve": ResolveCmd,
195 - "version": VersionCmd,
198 }
199
200 func init() {
201 Root.ProcessHelp()
202 *RootRO = *Root
203
202 - // sanitize readonly refs command
203 - *RefsROCmd = *RefsCmd
204 - RefsROCmd.Subcommands = map[string]*cmds.Command{}
205 -
204 // this was in the big map definition above before,
205 // but if we leave it there lgc.NewCommand will be executed
206 // before the value is updated (:/sanitize readonly refs command/)
207 +
208 + // sanitize readonly refs command
209 + *RefsROCmd = *RefsCmd
210 + RefsROCmd.Subcommands = map[string]*cmds.Command{}
211 rootROSubcommands["refs"] = RefsROCmd
212
211 - Root.Subcommands = rootSubcommands
213 + // sanitize readonly version command (no need to expose precise deps)
214 + *VersionROCmd = *VersionCmd
215 + VersionROCmd.Subcommands = map[string]*cmds.Command{}
216 + rootROSubcommands["version"] = VersionROCmd
217
218 + Root.Subcommands = rootSubcommands
219 RootRO.Subcommands = rootROSubcommands
220 }
221