A program or program
snippet is rewritten to conform to site-specific properties prior to being executed by a target host. The program or program
snippet directed to a target host from a known or
unknown source is either intercepted by a
server before reaching the target host or can be redirected from the target host to the
server to effect its
rewriting. The program is parsed in its external representation, converting it to an internal representation that is inspected and analyzed with reference to
a site-specific properties
database. A summary of the program's properties is then compared to the site-specific properties
database by a binary
rewriting engine, which produces a rewritten program in an internal representation. If appropriate, the program or program
snippet is rewritten to convert it to a format suitable for execution on the target host. Furthermore, certifications may be added to the rewritten program to mark that the rewritten program obeys site-specific constraints. The
rewriting service thus produces a program in an appropriate target representation that conforms to site-specific properties. These properties may relate to security, auditing, optimization, monitoring, threading, and / or management of the rewritten program.