Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
A interpreter for programs written in the Apartment List dialect of Karel.
Add this line to your application's Gemfile:
gem 'karel-interpreter'
The interpreter takes a single file as an argument and prints out the final state of the Karel grid after executing the program.
# square_dance.krl
move
put
turn_left
move
turn_left
move
put
turn_left
move
% karel square_dance.krl
location: (0, 0)
direction: right
tokens: [{"location"=>"(-1, 0)", "count"=>1}, {"location"=>"(0, 1)", "count"=>1}]
operations: 9
Karel is a creature that lives on an infinite two dimensional grid. Using built-in commands as the basic building blocks, rudimentary control flow, and user-defined commands, programs can move Karel around the grid and place and remove tokens from squares on the grid.
The Karel language is case-sensitive and indentation-sensitive. All built-in commands and reserved words for control flow and user-defined commands are lower case. Statements within the body of control flow branches and user-defined commands must be indented two spaces beyond the containing branch/command definition. Only one statement is allowed per line. Blank lines are permitted.
Comments begin with a #
and continue to the end of the line. Comments can be placed
on their own line or after a statement.
The following commands are available out of the box.
move
- Move Karel one square forward in the direction she is facingturn_left
- Turn Karel left (CCW) 90 degreestoken?
- Return true
if there is one or more tokens on Karel's current location, otherwise falsepick
- Pick up one token from Karel's current location. If there are no tokens, this command will crash the program.put
- Put one token down on Karel's current location.Karel responds to if
/else
branching and while
loops. The condition evaluated for
these two control flow structures can be negated with a !
(no spaces are allowed between
the negation operator and the condition)
if
statementif token?
pick
end
if
/else
if token?
pick
else
move
end
if !token?
put
end
if
if token?
pick
if token?
move
end
end
while
statement# This will safely remove all tokens from a square.
while token?
pick
end
The Karel language supports user-defined commands. These commands do not take arguments and do not return a value. Commands are defined with the following syntax
def <command-name>
<statement-1>
<statement-2>
...
end
def turn_around
turn_left
turn_left
end
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.
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.
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/karel-interpreter. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
The gem is available as open source under the terms of the MIT License.
Everyone interacting in the Karel::Interpreter project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.
FAQs
Unknown package
We found that karel-interpreter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.