Commit graph

1102 commits

Author SHA1 Message Date
mountford
c85dc0c089 Avoid showing personal contact data in RDAP when not logged in
This CL changes the RDAP responses. When the requester asks for information about a domain, and is not logged in as the owning registrar, no contact information is shown. When the requester asks for information about a contact, and is not logged in as the owner registrar, the existence of the contact is shown, but not any personal data (the existence is shown to make things easier to test).

The login uses the same functionality as the registrar console.

For the most part, this CL does not include the necessary tests to make sure that data is not returned when not logged in. The CL is so large that I didn't want to burden it further. Those tests will be added in a follow-on CL.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=168022034
2017-09-12 15:51:50 -04:00
guyben
f0621c4df1 Add unit tests to RequestStatusCheckerImpl
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=167742899
2017-09-12 15:51:50 -04:00
bbilbo
3687cc5138 Qualify the usage of ImmutableSet.of()
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=167718824
2017-09-12 15:51:50 -04:00
guyben
c3861f6e95 Swap all uses of Lock to LockHandler
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=167661348
2017-09-12 15:51:50 -04:00
bbilbo
57bcd6b1eb Declare types in ImmutableSet.of() usage
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=167625611
2017-09-12 15:51:50 -04:00
guyben
fa70bd272a Add tool to check if other requests are still running
This is needed for the Lock.java enhancement where a lock will be implicitly
released if the request owning it dies.

No matter which solution we want for refactoring the Lock itself, we will need this class.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=167600314
2017-09-12 15:51:50 -04:00
guyben
18a13a09a4 Add request/lock to opensource build
This is to fix Kokoro, given the directory added in [] Also, added forgotten keyring/api directory.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=167598465
2017-09-12 15:51:50 -04:00
bbilbo
2e4b63bb79 Add support for a domain transfer request superuser EPP extension
Allow superusers to change the transfer period to zero years and allow
superusers to change the automatic transfer length.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=167598314
2017-09-12 15:51:50 -04:00
bbilbo
263aea3b2a Add logging to WhoisReader
Logging will make it easier to troubleshoot WhoisServer exceptions.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=167596453
2017-09-12 15:51:50 -04:00
guyben
978149e677 Create an injectable LockHandler
We create an injectable LockHandler that just calls the static
Lock.executeWithLocks function.

I'm not sure what's the correct place to put the LockHandler. I think
model/server is only appropriate for the actual datastore lock. This is a "per request" lock, so maybe request/lock?

-----------------------------

This is the initial step in adding the "lock implicitly released on request death" feature, but it's also useful on its own - easier to test Actions when we can use a fake lock.

To keep this CL simple, we keep using the old Lock as is in most places. We just choose a single example to convert to LockHandler to showcase it. Converting all other uses will be in a subsequent CL.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=167357564
2017-09-12 15:51:50 -04:00
mmuller
8aadf137fb Create an entity record accumulator
RecordAccumulator builds a set of datastore Entity records from a set of
leveldb logfiles in a directory tree (which is how we receive them for
database backup/restore testing).

This CL also refactors some of the logfile test code out of
LevelDbLogReaderTest so that we can reuse it for building test logs.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=167313553
2017-09-12 15:51:50 -04:00
larryruili
06f3215659 Add transaction report generation code
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=167311547
2017-09-12 15:51:50 -04:00
mmuller
f26bfbf632 Implement ComparableEntity class
ComparableEntity allows us to compare Entity objects by both key and
properties, regardless of the order of those properties in the protobufs.

This is necessary for comparing database backups, where we evaluate the
differences in the set of entities in one backup with those of another.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=167288489
2017-09-12 15:51:50 -04:00
larryruili
3809ff59a5 Filter cancellation records for only cancellable records
Previously, I would cancel all the records associated with HistoryEntry that's
available for cancellation. This could cause unexpected behavior if we
cancelled a historyEntry which itself had cancelled records (in effect we would
negate the negation unintentionally). This is easily remedied by only
cancelling records which want to be cancelled.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=167204383
2017-09-12 15:51:50 -04:00
dxy
d8c1501213 Add PollMapreduceAction
This is the first in a series of CLs containing code from an old CL of Dai's that had never been completed, which compares zone data between Datastore and DNS. I had written a script to do this by calling two nomulus commands, but maybe it can be done directly in Java, which would be convenient.

This CL is just the plumbing to check on the status of a Mapreduce. We will need this to know that we can proceed with the next step of comparing the output to the DNS data.

Cloned from CL 134295050 by 'g4 patch'.
Original change by dxy@dxy:zoneman-reader:1939:citc on 2016/09/26 10:34:22.

Add a command for comparing zone data between DNS and datastore

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=167188979
2017-09-12 15:51:44 -04:00
guyben
fa447ce37e Fix soft delete for possible double-map of domain
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=167040455
2017-09-12 14:57:34 -04:00
guyben
ccc51daa9f Add and fix mapreduce counters
Lessons from the first full run of the mapreduce.

Fixed the "old manifests still referenced" counter, since some of these
manifests could be new.

Added a debug "manifests incorrectly mapped multiple times" that is expected to never happen, but who knows? (this is a sort of sanity check for the mapreduce)

Added an "Epp resource revisions handled" that counts the total references, allowing for the possibility of the same manifest being referenced from multiple resources - this is expected to be equal to the map's "Epp resource revisions found" counter.

Added a "commit log manifests referenced multiple times" to see how often the same manifest is linked to from different epp resources.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=166846879
2017-08-29 17:21:43 -04:00
larryruili
63fdb506df Add explicit useLegacySql flag to UpdateSnapshotViewAction
It turns out the Bigquery JSON api selects its validator exclusively through
the useLegacySql flag (the #standardSQL directive isn't considered). To fix
this, we add back the explicit flag.

This also logs unexpected API errors, instead of allowing the job to quietly fail.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=166757569
2017-08-29 17:20:09 -04:00
larryruili
c86fd96654 Ignore test TLDs when logging transaction creates/deletes
The probers make a constant stream of create and delete calls, which we don't
want to account for when constructing transaction reports. This change will
cause only real TLDs to log create and delete transaction records.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=166737801
2017-08-29 17:18:39 -04:00
larryruili
16e8286dca Record domain transaction for domain transfers
This is the last of many cls adding explicit logging in all our domain
mutation flows to facilitate transaction reporting.

The transfer process is as follows:
GAINING sends a TransferRequest to LOSING
LOSING either acks (TransferApprove), nacks (TransferReject) or does nothing
(auto approve). For acks and autoapproves, we produce a +1 counter for GAINING
and LOSING for domain-gaining/losing-successful for each registrar, to be
reported on the approve date + the transfer grace period. For nacks, we produce
a +1 counter for domain-gaining/losing-nacked for each registrar.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=166535579
2017-08-29 17:17:07 -04:00
larryruili
7ee8bc9070 Record domain transaction for domain deletes
This is the third of many cls adding explicit logging in all our domain
mutation flows to facilitate transaction reporting.

We add a +1 counter for either grace or nograce deletes, based on the grace period status of the domain. We then search back in time for DOMAIN_CREATE, DOMAIN_RENEW and DOMAIN_AUTORENEW HistoryEntries off the same resource that happened in their corresponding grace periods (5, 5 and 45 days respectively). All transaction records for these events are then given -1 counters to properly account for cancellations in the NET_CREATE and NET_RENEW fields.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=166506010
2017-08-29 17:15:38 -04:00
mcilwain
d011b8e073 Fix Java 7 type inference issue in ExpandRecurringBillingEvents
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=166478634
2017-08-29 17:14:11 -04:00
jakubvrana
4a81236652 Use JSON.parse instead of deprecated goog.json.parse.
Thanks to [] shared libraries at Google now produce valid JSON which allows using JSON.parse. It is safer and faster than goog.json.parse which uses eval by default.

NOTE: All shared libraries producing JSON at Google were changed to produce valid JSON. However, if your code uses a custom way of producing JSON (not using the shared libraries) or if your code parses JSON generated a long time ago and stored, this CL might break you so please review with care.

Design doc: []

Tested:
    TAP --sample for global presubmit queue
    []

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=166454709
2017-08-29 17:12:44 -04:00
mcilwain
103b3d7608 Correct usages of DateTime.now() everywhere to DateTime.now(UTC)
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=166393128
2017-08-29 17:09:53 -04:00
larryruili
7fb44e4f66 Parent recurring billing events under separate HistoryEntries
To log autorenews, we currently run a mapreduce daily that creates synthetic
billing events for each recurring event past its due time. These are all
parented under the original recurring event, which allows these synthetic events to incorrectly stack on the original mutating entry.

We now explicitly create a new HistoryEntry of type DOMAIN_AUTORENEW to log
autorenews alongside other mutating EPP flows. These also parent DomainTransactionRecords for the NET_RENEWS_1_YEAR field, with the reporting time equal to the billing time (which accounts for the autorenew grace period).

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=166379700
2017-08-29 17:08:27 -04:00
larryruili
97581e519d Unnest transactionFieldAmount from DomainTransactionRecord
After working further with domain deletes, I realized we'll need to record multiple reportingTimes under a single historyEntry when issuing a -1 counter to cancel grace-period adds. Since the TLD would be the only shared component within a record, we'll just duplicate it across all records to save an unnecessary layer of hierarchy.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=166261413
2017-08-29 17:05:15 -04:00
guyben
f9a2415954 Check that CommitLogManifest exists before deletion
It appears that there are some possible flows where the reducer runs twice on
the same key. Either because of some error in a subsequent key that makes the
entire shard become ignored and retried, or possible some obscure error outside
of the transaction on that key.

The result however is that sometimes the reducer runs on a key that has already
been deleted. We need to check for that to prevent a null pointer exception.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=166112173
2017-08-29 17:02:12 -04:00
mountford
91d4fdb9a8 Modify GenerateZoneFilesAction to create output files more in line with standard DNS format
In standard DNS format, the first thing on an A, NS or DS definition line is a domain label relative to the zone, which in our case is a TLD. However, the generate_zone_files command prints out fully qualified host and domain names, resulting in a discrepancy when compared to the contents of the DNS subsystem. This CL removes the TLD suffix, which should remove one preprocessing step before file comparison.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=166103705
2017-08-29 17:00:41 -04:00
guyben
e94ab94d13 Shorten the lock timeout for rdeStaging
Sometimes rdeStaging reduce shards die after the lock is acquired. When that happens - the (automatic) rerun of the shard fails because the lock is in place causing that specific TLD to not stage and await the next call to rdeStaging.

rdeStaging runs every 4 hours, but the current lock lives for 5 hours.

This means that on the next rerun of rdeStaging, the lock still hasn't timed out so it fails again, and we have to wait for the subsequent run - a total delay of 8 hours.

Shortening the lock timeout to be less than the 4 hours rdeStaging rerun time solves this issue.

NOTE: This is just a "quick patch" solution. To really fix the rdeStaging failure we need to fix the lock itself.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=166102387
2017-08-29 16:59:18 -04:00
larryruili
c40dc67c5b Record transaction for domain adds, renews and allocates
This is the second of many cls adding explicit logging in all our domain
mutation flows to facilitate transaction reporting.

Adds and renews each result in a +1 counter for the NET_ADDS/RENEWS_#_YR field,
which I've added simple (# of years, add or renew) -> Enum functions to get.
Allocates are just a special case of adds, and are counted in a similar manner.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=165963249
2017-08-29 16:56:19 -04:00
jakubvrana
cb854f1b8b Fix build after []
Fixes []

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=165933643
2017-08-29 16:54:48 -04:00
Ben McIlwain
77c62219d5 Rename set to depset in .bzl and BUILD files
`set` is a deprecated alias for `depset` and will be removed soon. This change
does not change the behavior in any way.

More information: https://docs.google.com/document/d/1oeXoXGOsaUlre1NCap8RJDNNXX1x6RiXeJKhEzl5-qk
Tested:
    tap_presubmit
    Some tests failed; test failures are believed to be unrelated to this CL

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=165921608
2017-08-29 16:53:21 -04:00
mountford
e90e840757 Change GenerateZoneFilesAction to emit glue records only where appropriate
Previously, GenerateZoneFilesAction mapreduced its way through all domains and hosts for the specified TLD(s), emitting information for each matching domain and host (subject to constraints like not being deleted and so on). This resulted in host information (aka glue records) for all hosts subordinate to domains in the specified TLD(s). This is incorrect. DNS glue records should only be present for hosts which act as nameservers for their superordinate domains.

The new version of the mapreduce iterates only over domains. When a matching domain is found, a check is made to see whether any subordinate hosts are also nameservers for the domain, in which case host information is generated.

The test was updated to reflect the new reality, and check for a couple additional nuances.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=165766472
2017-08-29 16:51:35 -04:00
guyben
d5ac03aae4 Make DnsWriter truly atomic
Right now - if there's an error during DnsWriter.publish*, all the publish from
before that error will be committed, while all the publish after that error
will not.

More than that - in some writers partial publishes can be committed, depending
on implementation.

This defines a new contract that publish* are only committed when .commit is
called. That way any error will simply mean no publish is committed.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=165708063
2017-08-29 16:40:07 -04:00
mcilwain
fcb554947c Rename buildHistory() methods to buildHistoryEntry()
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=165707934
2017-08-29 16:38:39 -04:00
jianglai
dedabfb076 Make YamlUtils work with arbitrary classes
This makes it possible to use YamlUtils to configure the proxy.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=165639295
2017-08-29 16:37:11 -04:00
larryruili
2fe82921a7 Record domain transaction for DomainRestoreFlow
This is the first of many cls adding explicit logging in all our domain mutation flows to facilitate transaction reporting.

Restores are relatively simple- it happens immediately, so the reporting time is just the time of the HistoryEntry, and we add a single "RESTORED_DOMAINS" count of 1.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=165639084
2017-08-29 16:35:42 -04:00
larryruili
bf383081ce Add TransactionRecord to HistoryEntry for transaction reporting
This change adds the persisted data model necessary to facilitate transaction
reporting. TransactionRecord is an embedded repeated class within HistoryEntry
which is only added to when a HistoryEntry is created that counts towards
transaction reporting.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=165619552
2017-08-29 16:34:16 -04:00
mcilwain
46f175e078 Better handle deletion of prober domains
This implements a two-part deletion process for prober domains that were
not deleted properly by the prober (which is usually caused by a transient
network failure). The first time the mapreduce is run, such domains are
soft-deleted, so that their DNS entries can be removed correctly, and then
they are hard-deleted in the subsequent run.

Currently, all domains are hard-deleted the first time this mapreduce
runs, even if they were never soft-deleted correctly, which means that
their published DNS entries won't be correctly handled.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=165612973
2017-08-29 16:32:47 -04:00
mmuller
808f40890a Create a LevelDBLogReader class for java
This is a first step towards porting our database backup comparison tool
(which was written in Crack and subsequently in Python) to Java so that we can
run it in a reasonable amount of time.  Ideally, this functionality should be
available in Java, however the only instance of it that I can find is
currently deprecated without a replacement.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=165433766
2017-08-29 16:25:33 -04:00
larryruili
38abe9fa48 Optimize activity report SQL
We only log FLOW-LOG-SIGNATURE-METADATA from one place- FlowRunner. As a
result, we can swap the generalized regex for a prefix-only regex, saving a
<strong>lot</strong> of processing for our epp query (which is the most
expensive of the bunch).

I've also changed the test dates from 2017-05 to 2017-06, allowing us to copy-paste
the test data into Bigquery to verify their function. The reason for 2017-06 in particular is because June was the first month that populated all the metadata necessary to generate these reports.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=165391715
2017-08-29 16:22:27 -04:00
jianglai
9e7c996081 Add fallback headers to GFE specific headers
Currently we exact the client certificate hash from header X-GFE-SSL-Certificate. This works because the proxy running on [] sends the request directly to the AFE via HttpOverRpc, bypassing the frontline GFE, which would strip away this header.

[]

After the proxy moves to GCP we can no longer use that header. Instead we should use X-SSL-Certificate, which does not get stripped by the GFE. In fact the open source build should never have contained X-GFE-SSL-Certificate because obviously external nomulus users have to go through the GFE to reach the registry app and that header would never have survived.

Without changing how the [] proxy works, this CL makes the registry first try to extract the hash from X-GFE-SSL-Certificate, and fallback to X-SSL-Certificate if necessary. This allows the current setup to continue to work, while the new proxy is being tested.

This should not open us up to attacks because even if an attacker uses a proxy that uses X-SSL-Certificate, it still needs to pass OAuth in order to talk to /_dr/epp.

Similarly, we use X-Requested-Servername-SNI as fallback to X-GFE-Requested-Servername-SNI. This can be eliminated altogether when the [] proxy is retired, because the only reason we check if the client request is SNI enabled (by checking the existence of that header) is because the GFE only requests client certificate when SNI is enabled. The GCP proxy does not have that limitation, and also will be only serving one certificate with all SAN listed in it.

Some formatting change is also introduced by the formatter. They seem to be better conforming to the style guide, so I left them there.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=165378083
2017-08-29 16:21:00 -04:00
mmuller
f408833a72 Remove temporary variable in DNS queue logging
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=165181338
2017-08-29 16:09:39 -04:00
guyben
00f2662f33 Retry Datastore errors in CommitLogManifestReader.next()
When trying to run the MapReduce for DeleteOldCommitLogsAction, we run into a
lot of DatastoreTimeoutException during CommitLogManifestReader.next.

This causes the entire shard to fail. Since we have a lot of keys (tens of
millions), this is almost guaranteed to happen, dooming the entire MapReduce.

Here is an attempt to recover from the Timeout Exception by saving the state
before the read, then on failure restoring that state and trying again.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=165172222
2017-08-29 16:06:48 -04:00
mmuller
8b0b54e997 Log new tasks added to the dns-pull queue
Log tasks and task count on the input side of the queue so we can track which
things go in.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=165026523
2017-08-29 16:05:21 -04:00
lukes
4de8d3eae1 Migrate {css} and {xid} tags to new builtinfunctions css() and xid()
Output should be identical in either syntax, and migration will bring css and xid into consistency with other soy functions, plus it'll allow us to simplify the soy parser.

LSC: https://docs.google.com/document/d/1evNu02pVXGm1QIcN0dTmNi-GnhbCKOWdrZwBJmcNaU0/edit#

Tested:
    TAP --sample for global presubmit queue
    []

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=164887843
2017-08-29 15:56:43 -04:00
larryruili
477617eec9 Add activity report generation code
This adds Bigquery API client code to generate the activity reports from our
now standardSQL queries. The naming mirrors that of RDE (Staging generates the
reports and uploads them to GCS).

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=164656344
2017-08-29 15:53:33 -04:00
mountford
2547313ef9 Use config settings for DNS TTL values across all code
Attending to this old bug will improve our ability to perform zone comparisons between Datastore and the DNS provider. Right now, zone comparison finds some bogus differences, because the TTL we send to the DNS subsystem doesn't match the TTL we use when generating our local dump files.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=164635557
2017-08-29 15:50:44 -04:00
bbilbo
e786c8d6ff Add better testing of domain and host creation using multi-part TLDs
Added validation on domain creation, preventing a domain from being created if
it equals an existing TLD. Added domain create tests for domains using
multi-part TLDs that shared suffixes and prefixes. Added host create tests for
hosts using multi-part TLDs that shared suffixes.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=164297749
2017-08-29 15:47:50 -04:00
bbilbo
f3919e056d Allow admins to access registrar console without a RegistrarContact
This allows admins to access the registrar console without needing to be added
as a registrar contact. If they are a registrar contact, then that registrar
takes precedence.

Tested=In Alpha

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=164182623
2017-08-29 15:43:36 -04:00