{"id":42159064,"url":"https://github.com/rung/go-safecast","last_synced_at":"2026-01-26T19:57:33.073Z","repository":{"id":57549429,"uuid":"306310532","full_name":"rung/go-safecast","owner":"rung","description":"Go Library for safe type conversion to prevent integer overflow","archived":false,"fork":false,"pushed_at":"2020-10-23T02:46:43.000Z","size":348,"stargazers_count":15,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-06-18T18:49:13.389Z","etag":null,"topics":["go","golang","security"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rung.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-10-22T11:08:51.000Z","updated_at":"2024-06-18T18:49:13.390Z","dependencies_parsed_at":"2022-08-27T00:40:40.982Z","dependency_job_id":null,"html_url":"https://github.com/rung/go-safecast","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/rung/go-safecast","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rung%2Fgo-safecast","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rung%2Fgo-safecast/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rung%2Fgo-safecast/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rung%2Fgo-safecast/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rung","download_url":"https://codeload.github.com/rung/go-safecast/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rung%2Fgo-safecast/sbom","scorecard":{"id":789772,"data":{"date":"2025-08-11","repo":{"name":"github.com/rung/go-safecast","commit":"e454c685d50ad7c468b6d4ee82e0e4b3ae4ddd79"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.8,"checks":[{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":0,"reason":"Found 0/27 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go-merge.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/rung/go-safecast/go-merge.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go-merge.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/rung/go-safecast/go-merge.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go-pr.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/rung/go-safecast/go-pr.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go-pr.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/rung/go-safecast/go-pr.yml/main?enable=pin","Info:   0 out of   4 GitHub-owned GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/go-merge.yml:1","Warn: no topLevel permission defined: .github/workflows/go-pr.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 11 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-23T07:10:35.370Z","repository_id":57549429,"created_at":"2025-08-23T07:10:35.370Z","updated_at":"2025-08-23T07:10:35.370Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28786565,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-26T13:55:28.044Z","status":"ssl_error","status_checked_at":"2026-01-26T13:55:26.068Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["go","golang","security"],"created_at":"2026-01-26T19:57:29.985Z","updated_at":"2026-01-26T19:57:33.057Z","avatar_url":"https://github.com/rung.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-safecast\nLibrary for safe type conversion in Go\n\n# What is this\nThe type of `int` equals `int64` on 64-bit machine in Go.  \nWhen you convert `int`(`int64`) to `int32`, `int8` or `int6`, Your code could have Integer Overflow vulnerability.\n\nIn 2019, [Kubernetes](https://kubernetes.io/) had the vulnerability. and the vulnerability was found on [Security Audit Project](https://github.com/kubernetes/community/blob/master/sig-security/security-audit-2019/findings/Kubernetes%20Final%20Report.pdf) by Trail of Bits.  \nYou can use this library to prevent the vulnerability creation.\n\n**(This library is inspired by Kubernetes's Security Audit Report by Trail of Bits)**\n\n# Usage\n\n```go\nimport \"github.com/rung/go-safecast\"\n```\n\n## Convert int to int32 (instead of native int32() type conversion)\n```go\n\ti := 2147483647\n\ti32, err := safecast.Int32(i) // convert int to int32 in a safe way\n\tif err != nil {\n\t\treturn err\n\t}\n```\nThe function returns error when the value is out of the 32-bit range.  \nThis library also has `safecast.Int16` and `safecast.Int8`. You can use the functions in the same way as `safecast.Int32`\n\n## Convert string to int32 (instead of strconv.Atoi())\n```go\n\ts := \"2147483647\"\n\ti, err := safecast.Atoi32(s) // convert string to int32 in a safe way\n\tif err != nil {\n\t\treturn err\n\t}\n```\nThe function returns error when the value is out of the 32-bit range.  \nThis library also has `safecast.Atoi16` and `safecast.Atoi8`. You can use the functions in the same way as `safecast.Atoi32`  \n\n# What happens when overflows\n## Range of each integer\n|       | int32 (32bit signed integer)         | int16 (16bit signed integer) | int8 (8bit signed integer) | \n| :---: | :----------------------------------: | :--------------------------: | :------------------------: | \n| Range | From -2,147,483,648 to 2,147,483,647 | From -32,768 to 32,767       | From -128 to 127           | \n\n## When using native int32(), the code causes overflows\n[\u003cimg src=\"img/native-int32.png\" width=\"700px\"\u003e](https://play.golang.org/p/tyATM4dL33x)  \nNative int32() type conversion doesn't return error when the code cause integer overflow.\n\nLink: [Go Playground](https://play.golang.org/p/tyATM4dL33x)\n\n---\n\n## When using safecast.Int32() on this library, your code is safe\n[\u003cimg src=\"img/safecast-int32.png\" width=\"700px\"\u003e](https://play.golang.org/p/1xeeyt-feLI)  \nThis library returns error when the value is out of the 32-bit range.  \nSo you can convert integer in a safe way.  \n\nLink: [Go Playground](https://play.golang.org/p/1xeeyt-feLI)\n\n# License\n[MIT License](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frung%2Fgo-safecast","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frung%2Fgo-safecast","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frung%2Fgo-safecast/lists"}