https://github.com/deadkrolik/phargo
PHAR files parser written in GO
https://github.com/deadkrolik/phargo
file format golang parser phar php
Last synced: 4 months ago
JSON representation
PHAR files parser written in GO
- Host: GitHub
- URL: https://github.com/deadkrolik/phargo
- Owner: deadkrolik
- License: mit
- Created: 2018-01-17T11:50:03.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-02-02T11:13:31.000Z (over 8 years ago)
- Last Synced: 2024-06-21T01:43:22.815Z (almost 2 years ago)
- Topics: file, format, golang, parser, phar, php
- Language: Go
- Homepage:
- Size: 36.1 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PHARGO
PHAR-files reader and parser written in golang
## Info
Parser supports several signature algorithms:
* MD5
* SHA1
* SHA256
* SHA512
* ~~OPENSSL~~
Also supports compression formats:
* None
* GZ
* ~~BZ2~~
Can read manifest version, alias and metadata. For every file inside PHAR-archive can read it contents,
name, timestamp and metadata. Checks file CRC and signature of entire archive.
## Installation
1. Download and install:
```sh
$ go get -u github.com/deadkrolik/phargo
```
2. Import and use it:
```go
package main
import (
"log"
"time"
"github.com/deadkrolik/phargo"
)
func main() {
r := phargo.NewReader()
//some limitations
if false {
r.SetOptions(phargo.Options{
//metadata of every file and entire archive can be more than that number
MaxMetaDataLength: 10000,
//max length of first block of archive when looking for "HALT_COMPILER" string
MaxManifestLength: 1048576 * 100,
//max length of name of the file
MaxFileNameLength: 1000,
//max length of archive alias in manifest
MaxAliasLength: 1000,
})
}
file, err := r.Parse("file.phar")
if err != nil {
log.Println(err)
return
}
log.Println("Manifest version: ", file.Version)
log.Println("File alias: ", file.Alias)
log.Println("Serialized metadata: ", string(file.Metadata))
for _, f := range file.Files {
log.Println("File name: ", f.Name)
log.Println("File metadata: ", string(f.Metadata))
log.Println("File data len: ", len(f.Data))
log.Println("File date: ", time.Unix(f.Timestamp, 0).String())
log.Println("---")
}
}
```
## Running the tests
Just run the command:
```sh
$ go test
```
## License
This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details