
Security News
New Website “Is It Really FOSS?” Tracks Transparency in Open Source Distribution Models
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.
= string_replacer
Repeatedly replace text in a file without disturbing the rest of the file.
== Use
$ string_replacer PATH STRING [REPLACEMENT_ID] [AFTER_LINE]
For example:
$ echo "hello" > test.txt $ cat test.txt hello $ string_replacer test.txt "Don't forget to say "hello world"" "Just a reminder" $ cat test.txt hello
Don't forget to say "hello world"
Now I swap it out by using the same REPLACEMENT_ID...
$ string_replacer test.txt "YOU ARE STILL FORGETTING to say "hello world"" "Just a reminder" $ cat test.txt hello
YOU ARE STILL FORGETTING to say "hello world"
And finally, to demonstrate that REPLACEMENT_ID is case-sensitive...
$ string_replacer test.txt "Nevermind" "Just a Reminder" $ cat test.txt hello
YOU ARE STILL FORGETTING to say "hello world"
Nevermind
If you don't specify REPLACEMENT_ID, it will default to "1."
== Real-world usage
http://brighterplanet.com uses it to unmask the memcached 1.4.4 package on http://engineyard.com AppCloud (i.e. Amazon EC2) instances.
We have this in our before_restart.rb hook:
###############################################################
############################################################### sudo 'gem install string_replacer --no-rdoc --no-ri'
###############################################################
###############################################################
memcached_server_version = '1.4.4'
unless /usr/bin/memcached -h
.include?(memcached_server_version)
sudo "/usr/bin/string_replacer /etc/portage/package.keywords/local "=net-misc/memcached-#{memcached_server_version}" "make sure memcached #{memcached_server_version} is available""
sudo "emerge net-misc/memcached"
end
sudo "cp #{release_path}/deploy/memcached/memcached.#{node[:environment][:name]} /etc/conf.d/memcached"
Before:
$ cat /etc/portage/package.keywords/local =dev-lang/ruby-1.8.7_p174
After:
$ cat /etc/portage/package.keywords/local =dev-lang/ruby-1.8.7_p174
=net-misc/memcached-1.4.4
== Obvious flaws
== Copyright
Copyright (c) 2010 Seamus Abshere. See LICENSE for details.
FAQs
Unknown package
We found that string_replacer 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
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.
Security News
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
Security News
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.