feat: register all file capabilities as unsafe to jsmod
This commit is contained in:
parent
1c0612ab08
commit
18e85b1ff1
@ -1,5 +1,8 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## [1.3.3] - 2026-05-30
|
||||||
|
- **新增**: 注册到 `jsmod`,将所有文件操作方法(Read/Write/Archive 等)注册为高危方法(unsafeList),确保安全沙箱隔离。
|
||||||
|
|
||||||
## [1.0.7] - 2026-05-06
|
## [1.0.7] - 2026-05-06
|
||||||
- **设计哲学对齐**:全面废除 `Must` 前缀函数(`MustRead`, `MustReadBytes`, `MustReadLines`, `MustReadDir`, `MustGzip`, `MustGunzip`, `MustZip`, `MustUnzip`),改为配合 `go/cast` 的 `As` 函数消除摩擦。
|
- **设计哲学对齐**:全面废除 `Must` 前缀函数(`MustRead`, `MustReadBytes`, `MustReadLines`, `MustReadDir`, `MustGzip`, `MustGunzip`, `MustZip`, `MustUnzip`),改为配合 `go/cast` 的 `As` 函数消除摩擦。
|
||||||
- **内部优化**:重构 `memory.go` 以移除对废弃 `Must` 函数的内部依赖。
|
- **内部优化**:重构 `memory.go` 以移除对废弃 `Must` 函数的内部依赖。
|
||||||
|
|||||||
1
go.mod
1
go.mod
@ -5,6 +5,7 @@ go 1.25.0
|
|||||||
require (
|
require (
|
||||||
apigo.cc/go/cast v1.3.3
|
apigo.cc/go/cast v1.3.3
|
||||||
apigo.cc/go/encoding v1.3.1
|
apigo.cc/go/encoding v1.3.1
|
||||||
|
apigo.cc/go/jsmod v1.0.0
|
||||||
apigo.cc/go/safe v1.3.1
|
apigo.cc/go/safe v1.3.1
|
||||||
gopkg.in/yaml.v3 v3.0.1
|
gopkg.in/yaml.v3 v3.0.1
|
||||||
)
|
)
|
||||||
|
|||||||
2
go.sum
2
go.sum
@ -2,6 +2,8 @@ apigo.cc/go/cast v1.3.3 h1:aln5eDR5DZVWVzZ/y5SJh1gQNgWv2sT82I25NaO9g34=
|
|||||||
apigo.cc/go/cast v1.3.3/go.mod h1:lGlwImiOvHxG7buyMWhFzcdvQzmSaoKbmr7bcDfUpHk=
|
apigo.cc/go/cast v1.3.3/go.mod h1:lGlwImiOvHxG7buyMWhFzcdvQzmSaoKbmr7bcDfUpHk=
|
||||||
apigo.cc/go/encoding v1.3.1 h1:y8O58KYAyulkThg1O2ji2BqjnFoSvk42sit9I3z+K7Y=
|
apigo.cc/go/encoding v1.3.1 h1:y8O58KYAyulkThg1O2ji2BqjnFoSvk42sit9I3z+K7Y=
|
||||||
apigo.cc/go/encoding v1.3.1/go.mod h1:xAJk5b83VZ31mXMTnyp0dfMoBKfT/AHDn0u+cQfojgY=
|
apigo.cc/go/encoding v1.3.1/go.mod h1:xAJk5b83VZ31mXMTnyp0dfMoBKfT/AHDn0u+cQfojgY=
|
||||||
|
apigo.cc/go/jsmod v1.0.0 h1:lVQMq0tCno4kbHlQ3j5wzsm+v24J+bznIoHxpton0pE=
|
||||||
|
apigo.cc/go/jsmod v1.0.0/go.mod h1:bmyeZtOAP/j5am+YRnaiM89smysK24K7ebk0koFtsSw=
|
||||||
apigo.cc/go/rand v1.3.1 h1:7FvsI6PtQ5XrWER0dTiLVo0p7GIxRidT/TBKhVy93j8=
|
apigo.cc/go/rand v1.3.1 h1:7FvsI6PtQ5XrWER0dTiLVo0p7GIxRidT/TBKhVy93j8=
|
||||||
apigo.cc/go/rand v1.3.1/go.mod h1:mZ/4Soa3bk+XvDaqPWJuUe1bfEi4eThBj1XmEAuYxsk=
|
apigo.cc/go/rand v1.3.1/go.mod h1:mZ/4Soa3bk+XvDaqPWJuUe1bfEi4eThBj1XmEAuYxsk=
|
||||||
apigo.cc/go/safe v1.3.1 h1:irTCqPAC97gGsX/Lw5AzLelDt1xXLEZIAaVhLELWe9Q=
|
apigo.cc/go/safe v1.3.1 h1:irTCqPAC97gGsX/Lw5AzLelDt1xXLEZIAaVhLELWe9Q=
|
||||||
|
|||||||
38
js_export.go
Normal file
38
js_export.go
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
package file
|
||||||
|
|
||||||
|
import "apigo.cc/go/jsmod"
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
jsmod.Register("file", map[string]any{
|
||||||
|
"exists": Exists,
|
||||||
|
"read": Read,
|
||||||
|
"readBytes": ReadBytes,
|
||||||
|
"readLines": ReadLines,
|
||||||
|
"readDir": ReadDir,
|
||||||
|
"getFileInfo": GetFileInfo,
|
||||||
|
"getAbsFilename": GetAbsFilename,
|
||||||
|
"write": Write,
|
||||||
|
"writeBytes": WriteBytes,
|
||||||
|
"remove": Remove,
|
||||||
|
"mkdir": Mkdir,
|
||||||
|
"copy": Copy,
|
||||||
|
"move": Move,
|
||||||
|
"replace": Replace,
|
||||||
|
"unmarshalFile": UnmarshalFile,
|
||||||
|
"marshalFile": MarshalFile,
|
||||||
|
"marshalFilePretty": MarshalFilePretty,
|
||||||
|
"patchFile": PatchFile,
|
||||||
|
"archive": Archive,
|
||||||
|
"extract": Extract,
|
||||||
|
"compress": Compress,
|
||||||
|
"decompress": Decompress,
|
||||||
|
"readFileFromMemory": ReadFileFromMemory,
|
||||||
|
"readDirFromMemory": ReadDirFromMemory,
|
||||||
|
},
|
||||||
|
"exists", "read", "readBytes", "readLines", "readDir", "getFileInfo", "getAbsFilename",
|
||||||
|
"write", "writeBytes", "remove", "mkdir", "copy", "move", "replace",
|
||||||
|
"unmarshalFile", "marshalFile", "marshalFilePretty", "patchFile",
|
||||||
|
"archive", "extract", "compress", "decompress",
|
||||||
|
"readFileFromMemory", "readDirFromMemory",
|
||||||
|
)
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user