hrr_rb_syscall_lookup 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +20 -0
- data/.rspec +3 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +8 -0
- data/LICENSE.txt +21 -0
- data/README.md +105 -0
- data/Rakefile +14 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/demo/demo.rb +15 -0
- data/ext/hrr_rb_syscall_lookup/extconf.rb +8 -0
- data/ext/hrr_rb_syscall_lookup/hrr_rb_syscall_lookup.c +39 -0
- data/ext/hrr_rb_syscall_lookup/hrr_rb_syscall_lookup.h +6 -0
- data/hrr_rb_syscall_lookup.gemspec +22 -0
- data/lib/hrr_rb_syscall_lookup.rb +5 -0
- data/lib/hrr_rb_syscall_lookup/version.rb +3 -0
- metadata +61 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 79de27a80b93e3d2410f59d74b896ea1c7605f22c94f3c3337796d7d7641953a
|
4
|
+
data.tar.gz: 4c7bd7408d13e1266abf287bddd6f7f6f09a8a7c618d2a116310ed6ebbdb8eea
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 25dabbfcab5ae9c02544f85f710db4bc6776830e10939ab786cf1ef6ae12613545fa5aecff4cd250a1332a68d1eb743db5ba05bea4759febabf7b8e31bfef86a
|
7
|
+
data.tar.gz: f945a6c6bde0abe3433526d351cb3e7adf0e090eeda2cd9a879bc8ac525cfdd5c82a7b082bf9f6b391e45febff32b1858b98c10de77a509ff93c59c356483801
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at TODO: Write your email address. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [https://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: https://contributor-covenant.org
|
74
|
+
[version]: https://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 TODO: Write your name
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
# HrrRbSyscallLookup
|
2
|
+
|
3
|
+
HrrRbSyscallLookup is a library to provice system call number and name look-up functions using libaudit.
|
4
|
+
|
5
|
+
## Table of Contents
|
6
|
+
|
7
|
+
- [Requirements](#requirements)
|
8
|
+
- [Installation](#installation)
|
9
|
+
- [Usage](#usage)
|
10
|
+
- [Methods](#methods)
|
11
|
+
- [name_to_num(name)](#name_to_numname)
|
12
|
+
- [num_to_name(num)](#num_to_namenum)
|
13
|
+
- [Development](#development)
|
14
|
+
- [Contributing](#contributing)
|
15
|
+
- [Code of Conduct](#code-of-conduct)
|
16
|
+
- [License](#license)
|
17
|
+
|
18
|
+
## Requirements
|
19
|
+
|
20
|
+
HrrRbSyscallLookup requires the following is available on the system.
|
21
|
+
|
22
|
+
- libaudit
|
23
|
+
|
24
|
+
## Installation
|
25
|
+
|
26
|
+
Add this line to your application's Gemfile:
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
gem 'hrr_rb_syscall_lookup'
|
30
|
+
```
|
31
|
+
|
32
|
+
And then execute:
|
33
|
+
|
34
|
+
$ bundle install
|
35
|
+
|
36
|
+
Or install it yourself as:
|
37
|
+
|
38
|
+
$ gem install hrr_rb_syscall_lookup
|
39
|
+
|
40
|
+
## Usage
|
41
|
+
|
42
|
+
The basic usage for the library is as follows.
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
require "hrr_rb_syscall_lookup"
|
46
|
+
|
47
|
+
hello = "hello\n"
|
48
|
+
syscall HrrRbSyscallLookup.name_to_num("write"), $stdout.fileno, hello, hello.size
|
49
|
+
# hello
|
50
|
+
```
|
51
|
+
|
52
|
+
### Methods
|
53
|
+
|
54
|
+
#### name_to_num(name)
|
55
|
+
|
56
|
+
The name_to_num(name) method translates a system call name into a number that the name indicates based on the running machine.
|
57
|
+
|
58
|
+
```ruby
|
59
|
+
HrrRbSyscallLookup.name_to_num("write")
|
60
|
+
# => 1 # on my machine
|
61
|
+
```
|
62
|
+
|
63
|
+
The method takes an argument name that is an instance of String.
|
64
|
+
|
65
|
+
When the machine has the system call, the method returns a number, which an instance of Integer, that the name indicates.
|
66
|
+
|
67
|
+
When the machine does not have the system call, the method returns nil.
|
68
|
+
|
69
|
+
When the argument is not an instance of String, the method raises TypeError.
|
70
|
+
|
71
|
+
#### num_to_name(num)
|
72
|
+
|
73
|
+
The num_to_name(num) method translates a system call number into a name that the number indicates based on the running machine.
|
74
|
+
|
75
|
+
```ruby
|
76
|
+
HrrRbSyscallLookup.num_to_name(1)
|
77
|
+
# => write # on my machine
|
78
|
+
```
|
79
|
+
|
80
|
+
The method takes an argument num that is an instance of Integer.
|
81
|
+
|
82
|
+
When the machine has the system call, the method returns a name, which an instance of String, that the num indicates.
|
83
|
+
|
84
|
+
When the machine does not have the system call, the method returns nil.
|
85
|
+
|
86
|
+
When the argument is not an instance of Integer, the method raises TypeError.
|
87
|
+
|
88
|
+
## Development
|
89
|
+
|
90
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
91
|
+
|
92
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
93
|
+
|
94
|
+
## Contributing
|
95
|
+
|
96
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/hirura/hrr_rb_syscall_lookup. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/hirura/hrr_rb_syscall_lookup/blob/master/CODE_OF_CONDUCT.md).
|
97
|
+
|
98
|
+
|
99
|
+
## License
|
100
|
+
|
101
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
102
|
+
|
103
|
+
## Code of Conduct
|
104
|
+
|
105
|
+
Everyone interacting in the HrrRbSyscallLookup project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/hirura/hrr_rb_syscall_lookup/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rspec/core/rake_task"
|
3
|
+
|
4
|
+
RSpec::Core::RakeTask.new(:spec)
|
5
|
+
|
6
|
+
require "rake/extensiontask"
|
7
|
+
|
8
|
+
task :build => :compile
|
9
|
+
|
10
|
+
Rake::ExtensionTask.new("hrr_rb_syscall_lookup") do |ext|
|
11
|
+
ext.lib_dir = "lib/hrr_rb_syscall_lookup"
|
12
|
+
end
|
13
|
+
|
14
|
+
task :default => [:clobber, :compile, :spec]
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "hrr_rb_syscall_lookup"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/demo/demo.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require "hrr_rb_syscall_lookup"
|
2
|
+
|
3
|
+
puts "System call number of write:"
|
4
|
+
puts HrrRbSyscallLookup.name_to_num("write")
|
5
|
+
|
6
|
+
puts
|
7
|
+
|
8
|
+
puts "System call name of 1:"
|
9
|
+
puts HrrRbSyscallLookup.num_to_name(1)
|
10
|
+
|
11
|
+
puts
|
12
|
+
|
13
|
+
hello = "hello\n"
|
14
|
+
syscall HrrRbSyscallLookup.name_to_num("write"), $stdout.fileno, hello, hello.size
|
15
|
+
# => hello
|
@@ -0,0 +1,39 @@
|
|
1
|
+
#include <limits.h>
|
2
|
+
#include <libaudit.h>
|
3
|
+
#include "hrr_rb_syscall_lookup.h"
|
4
|
+
|
5
|
+
VALUE rb_mHrrRbSyscallLookup;
|
6
|
+
|
7
|
+
VALUE
|
8
|
+
name_to_num(VALUE self, VALUE name)
|
9
|
+
{
|
10
|
+
int rc;
|
11
|
+
Check_Type(name, T_STRING);
|
12
|
+
rc = audit_name_to_syscall(StringValueCStr(name), audit_detect_machine());
|
13
|
+
if (rc < 0)
|
14
|
+
return Qnil;
|
15
|
+
return INT2FIX(rc);
|
16
|
+
}
|
17
|
+
|
18
|
+
VALUE
|
19
|
+
num_to_name(VALUE self, VALUE num)
|
20
|
+
{
|
21
|
+
const char* name;
|
22
|
+
if (RB_TYPE_P(num, T_BIGNUM))
|
23
|
+
return Qnil;
|
24
|
+
Check_Type(num, T_FIXNUM);
|
25
|
+
if (FIX2LONG(num) < (long)INT_MIN || (long)INT_MAX < FIX2LONG(num))
|
26
|
+
return Qnil;
|
27
|
+
name = audit_syscall_to_name(FIX2INT(num), audit_detect_machine());
|
28
|
+
if (name == NULL)
|
29
|
+
return Qnil;
|
30
|
+
return rb_str_new_cstr(name);
|
31
|
+
}
|
32
|
+
|
33
|
+
void
|
34
|
+
Init_hrr_rb_syscall_lookup(void)
|
35
|
+
{
|
36
|
+
rb_mHrrRbSyscallLookup = rb_define_module("HrrRbSyscallLookup");
|
37
|
+
rb_define_singleton_method(rb_mHrrRbSyscallLookup, "name_to_num", name_to_num, 1);
|
38
|
+
rb_define_singleton_method(rb_mHrrRbSyscallLookup, "num_to_name", num_to_name, 1);
|
39
|
+
}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require_relative 'lib/hrr_rb_syscall_lookup/version'
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = "hrr_rb_syscall_lookup"
|
5
|
+
spec.version = HrrRbSyscallLookup::VERSION
|
6
|
+
spec.authors = ["hirura"]
|
7
|
+
spec.email = ["hirura@gmail.com"]
|
8
|
+
|
9
|
+
spec.summary = %q{Providing system call number and name look-up functions using libaudit.}
|
10
|
+
spec.description = %q{Providing system call number and name look-up functions using libaudit.}
|
11
|
+
spec.homepage = "https://github.com/hirura/hrr_rb_syscall_lookup"
|
12
|
+
spec.license = "MIT"
|
13
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.0.0")
|
14
|
+
|
15
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
16
|
+
|
17
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
18
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
19
|
+
end
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
spec.extensions = ["ext/hrr_rb_syscall_lookup/extconf.rb"]
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hrr_rb_syscall_lookup
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- hirura
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-02-29 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Providing system call number and name look-up functions using libaudit.
|
14
|
+
email:
|
15
|
+
- hirura@gmail.com
|
16
|
+
executables: []
|
17
|
+
extensions:
|
18
|
+
- ext/hrr_rb_syscall_lookup/extconf.rb
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- ".gitignore"
|
22
|
+
- ".rspec"
|
23
|
+
- CODE_OF_CONDUCT.md
|
24
|
+
- Gemfile
|
25
|
+
- LICENSE.txt
|
26
|
+
- README.md
|
27
|
+
- Rakefile
|
28
|
+
- bin/console
|
29
|
+
- bin/setup
|
30
|
+
- demo/demo.rb
|
31
|
+
- ext/hrr_rb_syscall_lookup/extconf.rb
|
32
|
+
- ext/hrr_rb_syscall_lookup/hrr_rb_syscall_lookup.c
|
33
|
+
- ext/hrr_rb_syscall_lookup/hrr_rb_syscall_lookup.h
|
34
|
+
- hrr_rb_syscall_lookup.gemspec
|
35
|
+
- lib/hrr_rb_syscall_lookup.rb
|
36
|
+
- lib/hrr_rb_syscall_lookup/version.rb
|
37
|
+
homepage: https://github.com/hirura/hrr_rb_syscall_lookup
|
38
|
+
licenses:
|
39
|
+
- MIT
|
40
|
+
metadata:
|
41
|
+
homepage_uri: https://github.com/hirura/hrr_rb_syscall_lookup
|
42
|
+
post_install_message:
|
43
|
+
rdoc_options: []
|
44
|
+
require_paths:
|
45
|
+
- lib
|
46
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: 2.0.0
|
51
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
requirements: []
|
57
|
+
rubygems_version: 3.0.3
|
58
|
+
signing_key:
|
59
|
+
specification_version: 4
|
60
|
+
summary: Providing system call number and name look-up functions using libaudit.
|
61
|
+
test_files: []
|