Comments are pouring in over an internal memo an unnamed male software engineer at Google sent to co-workers on Friday challenging some of the tech giant's diversity efforts, such as mentoring programs open only to people of a certain race or gender. Gizmodo posted the memo on the internet on Saturday and it since has gone viral. The memo contains such provocative statements as:

"Women, on average, have more: Openness directed towards feelings and aesthetics rather than ideas. Women generally also have a stronger interest in people rather than things, relative to men (also interpreted as empathizing vs. systemizing). [¶] These two differences in part explain why women relatively prefer jobs in social or artistic areas. More men may like coding because it requires systemizing and even within SWEs (software engineers), comparatively more women work on front end, which deals with both people and aesthetics." (Read 10 of the most shocking quotes from thememo.)

Many inside and outside of Google have called for the man's dismissal. However, there are at least three ways the law may keep the company from imposing any discipline.

First, federal labor law bars even non-union employers like Google from punishing an employee for communicating with fellow employees about improving working conditions. The purpose of the memo was to persuade Google to abandon certain diversity-related practices the engineer found objectionable and to convince co-workers to join his cause, or at least discuss the points he raised.

In a reply to the initial outcry over his memo, the engineer added to his memo: "Despite what the public response seems to have been, I've gotten many personal messages from fellow Googlers expressing their gratitude for bringing up these very important issues which they agree with but would never have the courage to say or defend because of our shaming culture and the possibility of being fired." The law protects that kind of "concerted activity."

Second, the engineer's memo largely is a statement of his political views as they apply to workplace policies. The memo is styled as a lament to "Google's Ideological Echo Chamber." California law prohibits employers from threatening to fire employees to get them to adopt or refrain from adopting a particular political course of action.

Danielle Brown, Google's newly installed vice president of Diversity, Integrity, & Governance, made it clear that the engineer's memo does not reflect "a viewpoint that I or this company endorses, promotes or encourages."

An employee does not have free reign to engage in political speech that disrupts the workplace, but punishing an employee for deviating from company orthodoxy on a political issue is not allowed either. Brown acknowledged that when she wrote that "an open, inclusive environment means fostering a culture in which those with alternative views, including different political views, feel safe sharing their opinions."

Third, the engineer complained in parts of his memo about company policies that he believes violate employment discrimination laws. Those policies include support programs limited by race or gender and promotional and hiring scoring policies that consider race and gender. It is unlawful for an employer to discipline an employee for challenging conduct that the employee reasonably believed to be discriminatory, even when a court later determines the conduct was not actually prohibited by the discrimination laws. In other words, the engineer doesn't have to be right that some of Google's diversity initiatives are unlawful, only that he reasonably believes that they are.

Brown is correct that an employee has no right to engage in workplace discourse that offends anti-discrimination laws; employees may not engage in unlawful harassment under the guise of protected concerted activity or political grievances.

The lawful response to this software engineer's memo, however, appears to be continuation of the dialogue he started rather than termination of his employment.

Commentary by Dan Eaton, a partner with the San Diego law firm of Seltzer Caplan McMahon Vitek, where his practice focuses on defending and advising employers. He also is a professor at the San Diego State University Fowler College of Business where he teaches classes in business ethics and employment law. Follow him on Twitter @DanEatonlaw.

For more insight from CNBC contributors, follow @CNBCopinion on Twitter.