Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
language: go
go:
- 1.x
script:
- go test -v ./...
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018 phinexdaz

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# ipapk
ipa or apk parser written in golang, aims to extract app information

[![Build Status](https://travis-ci.org/phinexdaz/ipapk.svg?branch=master)](https://travis-ci.org/phinexdaz/ipapk)

## INSTALL
$ go get github.com/phinexdaz/ipapk

## USE
## USAGE
```go
package main

Expand Down
25 changes: 14 additions & 11 deletions parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,17 @@ import (
"github.com/shogo82148/androidbinary/apk"
)

var reInfoPlist = regexp.MustCompile(`Payload/[^/]+/Info\.plist`)
var (
reInfoPlist = regexp.MustCompile(`Payload/[^/]+/Info\.plist`)
ErrNoIcon = errors.New("icon not found")
)

const (
iosExt = ".ipa"
androidExt = ".apk"
)

type appInfo struct {
type AppInfo struct {
Name string
BundleId string
Version string
Expand All @@ -49,7 +52,7 @@ type iosPlist struct {
CFBundleIdentifier string `plist:"CFBundleIdentifier"`
}

func NewAppParser(name string) (*appInfo, error) {
func NewAppParser(name string) (*AppInfo, error) {
file, err := os.Open(name)
if err != nil {
return nil, err
Expand Down Expand Up @@ -125,17 +128,17 @@ func parseAndroidManifest(xmlFile *zip.File) (*androidManifest, error) {
return manifest, nil
}

func parseApkFile(xmlFile *zip.File) (*appInfo, error) {
func parseApkFile(xmlFile *zip.File) (*AppInfo, error) {
if xmlFile == nil {
return nil, errors.New("AndroidManifest.xml is not found")
return nil, errors.New("AndroidManifest.xml not found")
}

manifest, err := parseAndroidManifest(xmlFile)
if err != nil {
return nil, err
}

info := new(appInfo)
info := new(AppInfo)
info.BundleId = manifest.Package
info.Version = manifest.VersionName
info.Build = manifest.VersionCode
Expand All @@ -154,17 +157,17 @@ func parseApkIconAndLabel(name string) (image.Image, string, error) {
Density: 720,
})
if icon == nil {
return nil, "", errors.New("Icon is not found")
return nil, "", ErrNoIcon
}

label, _ := pkg.Label(nil)

return icon, label, nil
}

func parseIpaFile(plistFile *zip.File) (*appInfo, error) {
func parseIpaFile(plistFile *zip.File) (*AppInfo, error) {
if plistFile == nil {
return nil, errors.New("info.plist is not found")
return nil, errors.New("info.plist not found")
}

rc, err := plistFile.Open()
Expand All @@ -184,7 +187,7 @@ func parseIpaFile(plistFile *zip.File) (*appInfo, error) {
return nil, err
}

info := new(appInfo)
info := new(AppInfo)
if p.CFBundleDisplayName == "" {
info.Name = p.CFBundleName
} else {
Expand All @@ -199,7 +202,7 @@ func parseIpaFile(plistFile *zip.File) (*appInfo, error) {

func parseIpaIcon(iconFile *zip.File) (image.Image, error) {
if iconFile == nil {
return nil, errors.New("Icon is not found")
return nil, ErrNoIcon
}

rc, err := iconFile.Open()
Expand Down
4 changes: 2 additions & 2 deletions parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func TestParseIpaIcon(t *testing.T) {
break
}
}
if _, err := parseIpaIcon(iconFile); err.Error() != "Icon is not found" {
t.Errorf("got %v want %v", err, "Icon is not found")
if _, err := parseIpaIcon(iconFile); err != ErrNoIcon {
t.Errorf("got %v want %v", err, ErrNoIcon)
}
}
58 changes: 58 additions & 0 deletions vendor/github.com/DHowett/go-plist/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions vendor/github.com/DHowett/go-plist/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions vendor/github.com/DHowett/go-plist/bplist.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading